Class: FishjamClient
Defined in: js-server-sdk/src/client.ts:26
Client class that allows to manage Rooms and Peers for a Fishjam App. It requires the Fishjam ID and management token that can be retrieved from the Fishjam Dashboard.
Constructors​
Constructor​
new FishjamClient(
config):FishjamClient
Defined in: js-server-sdk/src/client.ts:50
Create new instance of Fishjam Client.
Does not verify credentials against the backend — use FishjamClient.create or call FishjamClient.checkCredentials afterwards for that.
Example usage:
const fishjamClient = new FishjamClient({ fishjamId: fastify.config.FISHJAM_ID, managementToken: fastify.config.FISHJAM_MANAGEMENT_TOKEN, });
Parameters​
| Parameter | Type |
|---|---|
config | FishjamConfig |
Returns​
FishjamClient
Methods​
checkCredentials()​
checkCredentials():
Promise<void>
Defined in: js-server-sdk/src/client.ts:102
Verifies the configured credentials by making a single lightweight call to the Fishjam backend. Resolves on success, throws InvalidFishjamCredentialsException on 401/404 from the backend, otherwise rethrows the standard mapped exception.
Returns​
Promise<void>
create()​
staticcreate(config):Promise<FishjamClient>
Defined in: js-server-sdk/src/client.ts:90
Async factory: constructs a client and verifies credentials against the backend.
Throws InvalidFishjamCredentialsException when the
fishjamId / managementToken pair is rejected by the backend.
Example:
const client = await FishjamClient.create({ fishjamId: process.env.FISHJAM_ID!, managementToken: process.env.FISHJAM_MANAGEMENT_TOKEN!, });
Parameters​
| Parameter | Type |
|---|---|
config | FishjamConfig |
Returns​
Promise<FishjamClient>
createAgent()​
createAgent(
roomId,options,callbacks?):Promise<{agent:FishjamAgent;peer:Peer; }>
Defined in: js-server-sdk/src/client.ts:181
Create a new agent assigned to a room.
Parameters​
| Parameter | Type |
|---|---|
roomId | RoomId |
options | PeerOptionsAgent |
callbacks? | AgentCallbacks |
Returns​
Promise<{ agent: FishjamAgent; peer: Peer; }>
createLivestreamStreamerToken()​
createLivestreamStreamerToken(
roomId):Promise<StreamerToken>
Defined in: js-server-sdk/src/client.ts:298
Creates a livestream streamer token for the given room.
Parameters​
| Parameter | Type |
|---|---|
roomId | RoomId |
Returns​
Promise<StreamerToken>
a livestream streamer token
createLivestreamViewerToken()​
createLivestreamViewerToken(
roomId):Promise<ViewerToken>
Defined in: js-server-sdk/src/client.ts:286
Creates a livestream viewer token for the given room.
Parameters​
| Parameter | Type |
|---|---|
roomId | RoomId |
Returns​
Promise<ViewerToken>
a livestream viewer token
createMoqAccess()​
createMoqAccess(
config?):Promise<MoqAccess>
Defined in: js-server-sdk/src/client.ts:310
Creates MoQ access.
Parameters​
| Parameter | Type |
|---|---|
config? | MoqAccessConfig |
Returns​
Promise<MoqAccess>
connection details containing the relay URL with the JWT embedded as a ?jwt= query parameter, and the token itself
createPeer()​
createPeer(
roomId,options):Promise<{peer:Peer;peerToken:string; }>
Defined in: js-server-sdk/src/client.ts:165
Create a new peer assigned to a room.
Parameters​
| Parameter | Type |
|---|---|
roomId | RoomId |
options | PeerOptionsWebRTC |
Returns​
Promise<{ peer: Peer; peerToken: string; }>
createRoom()​
createRoom(
config):Promise<Room>
Defined in: js-server-sdk/src/client.ts:130
Create a new room. All peers connected to the same room will be able to send/receive streams to each other.
Parameters​
| Parameter | Type |
|---|---|
config | RoomConfig |
Returns​
Promise<Room>
createVapiAgent()​
createVapiAgent(
roomId,options):Promise<{peer:Peer; }>
Defined in: js-server-sdk/src/client.ts:204
Create a new VAPI agent assigned to a room.
Parameters​
| Parameter | Type |
|---|---|
roomId | RoomId |
options | PeerOptionsVapi |
Returns​
Promise<{ peer: Peer; }>
deletePeer()​
deletePeer(
roomId,peerId):Promise<void>
Defined in: js-server-sdk/src/client.ts:232
Delete a peer - this will also disconnect the peer from the room.
Parameters​
| Parameter | Type |
|---|---|
roomId | RoomId |
peerId | PeerId |
Returns​
Promise<void>
deleteRoom()​
deleteRoom(
roomId):Promise<void>
Defined in: js-server-sdk/src/client.ts:142
Delete an existing room. All peers connected to this room will be disconnected and removed.
Parameters​
| Parameter | Type |
|---|---|
roomId | RoomId |
Returns​
Promise<void>
getAllRooms()​
getAllRooms():
Promise<Room[]>
Defined in: js-server-sdk/src/client.ts:153
Get a list of all existing rooms.
Returns​
Promise<Room[]>
getRoom()​
getRoom(
roomId):Promise<Room>
Defined in: js-server-sdk/src/client.ts:220
Get details about a given room.
Parameters​
| Parameter | Type |
|---|---|
roomId | RoomId |
Returns​
Promise<Room>
refreshPeerToken()​
refreshPeerToken(
roomId,peerId):Promise<string>
Defined in: js-server-sdk/src/client.ts:273
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​
| Parameter | Type |
|---|---|
roomId | RoomId |
peerId | PeerId |
Returns​
Promise<string>
refreshed peer token
subscribePeer()​
subscribePeer(
roomId,subscriberPeerId,publisherPeerId):Promise<void>
Defined in: js-server-sdk/src/client.ts:244
Subscribe a peer to another peer - this will make all tracks from the publisher available to the subscriber. Using this function only makes sense if subscribeMode is set to manual
Parameters​
| Parameter | Type |
|---|---|
roomId | RoomId |
subscriberPeerId | PeerId |
publisherPeerId | PeerId |
Returns​
Promise<void>
subscribeTracks()​
subscribeTracks(
roomId,subscriberPeerId,tracks):Promise<void>
Defined in: js-server-sdk/src/client.ts:256
Subscribe a peer to specific tracks from another peer - this will make only the specified tracks from the publisher available to the subscriber. Using this function only makes sense if subscribeMode is set to manual
Parameters​
| Parameter | Type |
|---|---|
roomId | RoomId |
subscriberPeerId | PeerId |
tracks | TrackId[] |
Returns​
Promise<void>