Skip to content

Latest commit

 

History

History
325 lines (179 loc) · 8.18 KB

Transport_WebSocketTransportNJS.WebSocketTransportNJS.md

File metadata and controls

325 lines (179 loc) · 8.18 KB

@epicgames-ps/lib-pixelstreamingcommon-ue5.5 / Transport/WebSocketTransportNJS / WebSocketTransportNJS

Class: WebSocketTransportNJS

Transport/WebSocketTransportNJS.WebSocketTransportNJS

An implementation of WebSocketTransport from pixelstreamingcommon that supports node.js websockets This is needed because of the slight differences between the 'ws' node.js package and the websockets supported in the browsers. Do not use this code in a browser use 'WebSocketTransport' instead.

Hierarchy

  • EventEmitter

    WebSocketTransportNJS

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new WebSocketTransportNJS(existingSocket?): WebSocketTransportNJS

Parameters

Name Type
existingSocket? WebSocket

Returns

WebSocketTransportNJS

Overrides

EventEmitter.constructor

Defined in

Transport/WebSocketTransportNJS.ts:18

Properties

WS_OPEN_STATE

WS_OPEN_STATE: number = 1

Defined in

Transport/WebSocketTransportNJS.ts:15


onMessage

Optional onMessage: (msg: BaseMessage) => void

Callback filled in by the SignallingProtocol and should be called by the transport when a new message arrives.

Type declaration

▸ (msg): void

Parameters
Name Type
msg BaseMessage
Returns

void

Implementation of

ITransport.onMessage

Defined in

Transport/WebSocketTransportNJS.ts:38


webSocket

Optional webSocket: WebSocket

Defined in

Transport/WebSocketTransportNJS.ts:16

Methods

close

close(): void

Closes the Websocket connection

Returns

void

Defined in

Transport/WebSocketTransportNJS.ts:114


connect

connect(connectionURL): boolean

Connect to the signaling server

Parameters

Name Type Description
connectionURL string The Address of the signaling server

Returns

boolean

If there is a connection

Implementation of

ITransport.connect

Defined in

Transport/WebSocketTransportNJS.ts:45


disconnect

disconnect(code?, reason?): void

Disconnect this transport.

Parameters

Name Type Description
code? number An optional disconnect code.
reason? string A descriptive string for the disconnect reason.

Returns

void

Implementation of

ITransport.disconnect

Defined in

Transport/WebSocketTransportNJS.ts:56


handleOnClose

handleOnClose(event): void

Handles when the Websocket is closed

Parameters

Name Type Description
event CloseEvent Close Event

Returns

void

Defined in

Transport/WebSocketTransportNJS.ts:107


handleOnError

handleOnError(event): void

Handles when there is an error on the websocket

Parameters

Name Type Description
event ErrorEvent Error Payload

Returns

void

Defined in

Transport/WebSocketTransportNJS.ts:99


handleOnMessage

handleOnMessage(event): void

Handles what happens when a message is received

Parameters

Name Type Description
event MessageEvent Message Received

Returns

void

Defined in

Transport/WebSocketTransportNJS.ts:74


handleOnOpen

handleOnOpen(event): void

Handles when the Websocket is opened

Parameters

Name Type Description
event Event Not Used

Returns

void

Defined in

Transport/WebSocketTransportNJS.ts:91


isConnected

isConnected(): boolean

Should return true when the transport is connected and ready to send/receive messages.

Returns

boolean

True if the transport is connected.

Implementation of

ITransport.isConnected

Defined in

Transport/WebSocketTransportNJS.ts:66


sendMessage

sendMessage(msg): void

Sends a message over the websocket.

Parameters

Name Type Description
msg BaseMessage The message to send.

Returns

void

Implementation of

ITransport.sendMessage

Defined in

Transport/WebSocketTransportNJS.ts:31