## FhircastConnection class

A class representing a `FHIRcast` connection.

`FhircastConnection` extends `EventTarget` and emits 3 lifecycle events:

1. `connect` - An event to signal when a WebSocket connection has been opened. Fired as soon as a WebSocket emits `open`.
2. `message` - Contains a `payload` field containing a `FHIRcast` message payload exactly as it comes in over WebSockets.
3. `disconnect` - An event to signal when a WebSocket connection has been closed. Fired as soon as a WebSocket emits `close`.

To close the connection, call `connection.disconnect()` and listen to the `disconnect` event to know when the connection has been disconnected.

**Signature:**
```typescript
export declare class FhircastConnection extends TypedEventTarget<FhircastSubscriptionEventMap>
```

**Extends:** [TypedEventTarget](/content/docs/sdk/core.typedeventtarget) < [FhircastSubscriptionEventMap](/content/docs/sdk/core.fhircastsubscriptioneventmap) >

## Constructors

| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(subRequest)](/content/docs/sdk/core.fhircastconnection._constructor_/index.html) |  | Creates a new `FhircastConnection`. |

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [subRequest](/content/docs/sdk/core.fhircastconnection.subrequest) | `readonly` | [SubscriptionRequest](/content/docs/sdk/core.subscriptionrequest) |  |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [disconnect()](/content/docs/sdk/core.fhircastconnection.disconnect) |  |  |

- [FhircastConnection class](/content/docs/sdk/core.fhircastconnection#fhircastconnection-class/index.html)
- [Constructors](/content/docs/sdk/core.fhircastconnection#constructors/index.html)
- [Properties](/content/docs/sdk/core.fhircastconnection#properties/index.html)
- [Methods](/content/docs/sdk/core.fhircastconnection#methods/index.html)
