---title: Video.Clientsidebar_label: Client---import MethodOff from ../../_common/_method_off.mdx;import MethodOn from ../../_common/_method_on.mdx;import MethodOnce from ../../_common/_method_once.mdx;import MethodRemoveAllListeners from ../../_common/_method_removealllisteners.mdx;You can use instances of this class to subscribe to video events.#### Examplejavascriptconst 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
|#### Examplejavascriptconst video = new Video.Client({ project: , token: ,});## Methods### disconnect▸ **disconnect**(): voidDisconnects this client. The client will stop receiving events and you will need to create a new instance if you want to use it again.#### Returnsvoid#### Examplejsclient.disconnect();---### getRoomSessions▸ **getRoomSessions**(): Promise<{roomSessions: [RoomSession](./video-roomsession.mdx)[]}\>Returns the currently active room sessions.#### ReturnsPromise<{roomSessions: [RoomSession](./video-roomsession.mdx)[]}\>#### Exampletypescriptconst video = new Video.Client({ project: , token: ,});const { roomSessions } = await video.getRoomSessions();---### getRoomSessionById▸ **getRoomSessionById**(id): Promise<{roomSession: [RoomSession](./video-roomsession.mdx)}\>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. |#### Exampletypescriptconst 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).javascriptconst 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:javascriptconst video = new Video.Client(...)video.on(room.started, async (roomSession) => { console.log(roomSession.name)})#### Parameters| Name | Type || :------------ | :--------------------------------------- || roomSession | [RoomSession](./video-roomsession.mdx) |