You can use instances of this class to subscribe to video events. #### Example javascript const video = new Video.Client({ project: , token: }); video.on(room.started, async (roomSession) => { console.log(Room started); }); video.on(room.ended, async (roomSession) => { console.log(Room ended); }); const { roomSessions } = await video.getRoomSessions(); ## Constructors ### constructor • **new Client**(opts) Create a new Client instance. #### Parameters | Name | Type | Description | |:|:-|:--| | opts | Object | - | | opts.project | string | SignalWire project id, e.g. a10d8a9f-2166-4e82-56ff-118bc3a4840f
| | opts.token | string | SignalWire project token, e.g. PT9e5660c101cd140a1c93a0197640a369cf5f16975a0079c9
| | opts.debug? | Object | - | | opts.debug.logWsTraffic? | boolean | If true, logs all WebSocket traffic. Default is false. | #### Example javascript const video = new Video.Client({ project: , token: , }); ## Methods ### disconnect ▸ **disconnect**(): void Disconnects this client. The client will stop receiving events and you will need to create a new instance if you want to use it again. #### Returns void #### Example js client.disconnect(); ### getRoomSessions ▸ **getRoomSessions**(): Promise<{roomSessions: RoomSession[] }> - See [RoomSession](./video-roomsession.mdx) for more details. Returns the currently active room sessions. #### Returns Promise<{roomSessions: RoomSession[] }> - See [RoomSession](./video-roomsession.mdx) for more details. #### Example typescript const video = new Video.Client({ project: , token: , }); const { roomSessions } = await video.getRoomSessions(); ### getRoomSessionById ▸ **getRoomSessionById**(id): Promise<{roomSessions: RoomSession[] }> - See [RoomSession](./video-roomsession.mdx) for more details. Returns a room session given its id. Only in-progress room sessions are currently returned. #### Parameters | Name | Type | Description | |:--|:|:| | id | string | Id of the room session. | #### Example typescript const video = new Video.Client({ project: , token: , }); const { roomSession } = await video.getRoomSessionById(); ### off ### on ### once ### removeAllListeners ## Events ### room.ended • **room.ended**(roomSession) Emitted when a room session ends. Your event handler receives an object which is an instance of [Video.RoomSession](./video-roomsession.mdx). javascript const video = new Video.Client(...) video.on(room.ended, async (roomSession) => { console.log(roomSession.name) }) #### Parameters | Name | Type | |:--|:--| | roomSession | [RoomSession](./video-roomsession.mdx) | ### room.started • **room.started**(roomSession) Emitted when a room session is started. Your event handler receives an object which is an instance of [Video.RoomSession](./video-roomsession.mdx). Example: javascript const video = new Video.Client(...) video.on(room.started, async (roomSession) => { console.log(roomSession.name) }) #### Parameters | Name | Type | |:--|:--| | roomSession | [RoomSession](./video-roomsession.mdx) |