Skip to main content
Version: 0.21.0

Class: FishjamClient

Defined in: packages/js-server-sdk/packages/js-server-sdk/src/client.ts:13

Client class that allows to manage Rooms and Peers for a Fishjam App. It requires the Fishjam URL and management token that can be retrieved from the Fishjam Dashboard.

Constructors

Constructor

new FishjamClient(config): FishjamClient

Defined in: packages/js-server-sdk/packages/js-server-sdk/src/client.ts:30

Create new instance of Fishjam Client.

Example usage:

const fishjamClient = new FishjamClient({ fishjamUrl: fastify.config.FISHJAM_URL, managementToken: fastify.config.FISHJAM_MANAGEMENT_TOKEN, });

Parameters

ParameterType
configFishjamConfig

Returns

FishjamClient

Methods

createAgent()

createAgent(roomId, options, onError, onClose): Promise<{ agent: FishjamAgent; peer: Peer; }>

Defined in: packages/js-server-sdk/packages/js-server-sdk/src/client.ts:110

Create a new agent assigned to a room.

Parameters

ParameterType
roomIdRoomId
optionsPeerOptions
onErrorErrorEventHandler
onCloseCloseEventHandler

Returns

Promise<{ agent: FishjamAgent; peer: Peer; }>


createLivestreamStreamerToken()

createLivestreamStreamerToken(roomId): Promise<StreamerToken>

Defined in: packages/js-server-sdk/packages/js-server-sdk/src/client.ts:187

Creates a livestream streamer token for the given room.

Parameters

ParameterType
roomIdRoomId

Returns

Promise<StreamerToken>

a livestream streamer token


createLivestreamViewerToken()

createLivestreamViewerToken(roomId): Promise<ViewerToken>

Defined in: packages/js-server-sdk/packages/js-server-sdk/src/client.ts:174

Creates a livestream viewer token for the given room.

Parameters

ParameterType
roomIdRoomId

Returns

Promise<ViewerToken>

a livestream viewer token


createPeer()

createPeer(roomId, options): Promise<{ peer: Peer; peerToken: string; }>

Defined in: packages/js-server-sdk/packages/js-server-sdk/src/client.ts:90

Create a new peer assigned to a room.

Parameters

ParameterType
roomIdRoomId
optionsPeerOptions

Returns

Promise<{ peer: Peer; peerToken: string; }>


createRoom()

createRoom(config): Promise<Room>

Defined in: packages/js-server-sdk/packages/js-server-sdk/src/client.ts:48

Create a new room. All peers connected to the same room will be able to send/receive streams to each other.

Parameters

ParameterType
configRoomConfig

Returns

Promise<Room>


deletePeer()

deletePeer(roomId, peerId): Promise<void>

Defined in: packages/js-server-sdk/packages/js-server-sdk/src/client.ts:148

Delete a peer - this will also disconnect the peer from the room.

Parameters

ParameterType
roomIdRoomId
peerIdPeerId

Returns

Promise<void>


deleteRoom()

deleteRoom(roomId): Promise<void>

Defined in: packages/js-server-sdk/packages/js-server-sdk/src/client.ts:67

Delete an existing room. All peers connected to this room will be disconnected and removed.

Parameters

ParameterType
roomIdRoomId

Returns

Promise<void>


getAllRooms()

getAllRooms(): Promise<Room[]>

Defined in: packages/js-server-sdk/packages/js-server-sdk/src/client.ts:78

Get a list of all existing rooms.

Returns

Promise<Room[]>


getRoom()

getRoom(roomId): Promise<Room>

Defined in: packages/js-server-sdk/packages/js-server-sdk/src/client.ts:136

Get details about a given room.

Parameters

ParameterType
roomIdRoomId

Returns

Promise<Room>


refreshPeerToken()

refreshPeerToken(roomId, peerId): Promise<string>

Defined in: packages/js-server-sdk/packages/js-server-sdk/src/client.ts:161

Refresh the peer token for an already existing peer. If an already created peer has not been connected to the room for more than 24 hours, the token will become invalid. This method can be used to generate a new peer token for the existing peer.

Parameters

ParameterType
roomIdRoomId
peerIdPeerId

Returns

Promise<string>

refreshed peer token