# Interface UniversalWebSocket

Common WebSocket interface that can be implemented by different WebSocket-like classes This is compatible with the standard WebSocket API but allows for custom implementations

interface UniversalWebSocket {
binaryType: "arraybuffer" | "blob";
bufferedAmount: number;
CLOSED: 3;
CLOSING: 2;
CONNECTING: 0;
extensions: string;
onclose?: ((event: RivetCloseEvent) => void) | null;
onerror?: ((event: RivetEvent) => void) | null;
onmessage?: ((event: RivetMessageEvent) => void) | null;
onopen?: ((event: RivetEvent) => void) | null;
OPEN: 1;
protocol: string;
readyState: 0 | 1 | 2 | 3;
url: string;
addEventListener(type: string, listener: (event: any) => void): void;
close(code?: number, reason?: string): void;
dispatchEvent(event: RivetEvent): boolean;
removeEventListener(type: string, listener: (event: any) => void): void;
send(
data:
| string
| ArrayBufferLike
| Blob
| ArrayBufferView<ArrayBufferLike>,
): void;
}

#### Implemented by

- InlineWebSocketAdapter2

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:32

##### Index

### Properties

binaryType
bufferedAmount
CLOSED
CLOSING
CONNECTING
extensions
onclose?
onerror?
onmessage?
onopen?
OPEN
protocol
readyState
url

### Methods

addEventListener
close
dispatchEvent
removeEventListener
send

## Properties

### binaryType

binaryType: "arraybuffer" | "blob"

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:41

### `Readonly` bufferedAmount

bufferedAmount: number

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:42

### `Readonly` CLOSED

CLOSED: 3

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:37

### `Readonly` CLOSING

CLOSING: 2

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:36

### `Readonly` CONNECTING

CONNECTING: 0

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:34

### `Readonly` extensions

extensions: string

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:43

### `Optional` onclose

onclose?: ((event: RivetCloseEvent) => void) | null

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:56

### `Optional` onerror

onerror?: ((event: RivetEvent) => void) | null

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:57

### `Optional` onmessage

onmessage?: ((event: RivetMessageEvent) => void) | null

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:58

### `Optional` onopen

onopen?: ((event: RivetEvent) => void) | null

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:55

### `Readonly` OPEN

OPEN: 1

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:35

### `Readonly` protocol

protocol: string

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:44

### `Readonly` readyState

readyState: 0 | 1 | 2 | 3

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:40

### `Readonly` url

url: string

- Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:45

## Methods

### addEventListener

- addEventListener(type: string, listener: (event: any) => void): void

  #### Parameters

  - type: string
  - listener: (event: any) => void

  #### Returns void

  - Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:50

### close

- close(code?: number, reason?: string): void

  #### Parameters

  - `Optional` code: number
  - `Optional` reason: string

  #### Returns void

  - Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:49

### dispatchEvent

- dispatchEvent(event: RivetEvent): boolean

  #### Parameters

  - event: RivetEvent

  #### Returns boolean

  - Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:52

### removeEventListener

- removeEventListener(type: string, listener: (event: any) => void): void

  #### Parameters

  - type: string
  - listener: (event: any) => void

  #### Returns void

  - Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:51

### send

- send(
  data: string | ArrayBufferLike | Blob | ArrayBufferView<ArrayBufferLike>,
  ): void

  #### Parameters

  - data: string | ArrayBufferLike | Blob | ArrayBufferView<ArrayBufferLike>

  #### Returns void

  - Defined in rivetkit-typescript/packages/rivetkit/src/common/websocket-interface.ts:48