Search…
Room

Televisit Room

Configuring Room Triggers

There are three special trigger events for the room object: room.after, participant.after and track.after. Each occurs in response to a web hook call from the video provider. These events are also recorded in the room's events[] list.
Note recording.after and composition.after will be implemented in future versions.
To handle events triggered by the remote room provider, insert these Cortex script triggers.
1
org.objects.scripts.insertMany([{
2
type: 'trigger',
3
active: true,
4
configuration: {
5
event: 'room.after',
6
object: 'room',
7
},
8
description: 'c_room_room_event',
9
label: 'c_room_room_event',
10
name: 'c_room_room_event',
11
principal: null,
12
script: `
13
const { arguments: { event, old: room }, context } = script
14
require('logger').trace(event)
15
`
16
},{
17
type: 'trigger',
18
active: true,
19
configuration: {
20
event: 'participant.after',
21
object: 'room',
22
},
23
description: 'c_room_participant_event',
24
label: 'c_room_participant_event',
25
name: 'c_room_participant_event',
26
principal: null,
27
script: `
28
const { arguments: { event, old: room }, context } = script
29
require('logger').trace(event)
30
`
31
},{
32
type: 'trigger',
33
active: true,
34
configuration: {
35
event: 'track.after',
36
object: 'room',
37
},
38
description: 'c_room_track_event',
39
label: 'c_room_track_event',
40
name: 'c_room_track_event',
41
principal: null,
42
script: `
43
const { arguments: { event, old: room }, context } = script
44
require('logger').trace(event)
45
`
46
}]).execute()
Copied!

Room Events

All room events share the following properties:
    type { String } Indexed room event type [room, participant, track]
    name { String } Indexed room event name. created, ended, connected, etc.
    order { Number } Indexed integer representing the order in which the remote event was fired. It's possible that
    events are called and written out of order. The order property may be used to present the remote timeline.
    roomId { ObjectID } Indexed originating local room identifier.

room.after :: room.created - Room is open and available for connection.

1
{
2
type: 'room',
3
name: 'created',
4
order: 0,
5
roomId: '5df02d890535377c38cfdeef'
6
}
Copied!

room.after :: room.ended - Room is closed, or ended due to a timeout (empty for 5 minutes).

    duration { Number } The number of seconds the room was active.
1
{
2
type: 'room',
3
name: 'ended',
4
order: 12,
5
roomId: '5df02d890535377c38cfdeef',
6
duration: 156
7
}
Copied!

participant.after :: participant.connected - Participant entered a room

    status { String } The current status of the participant generating this event - either connected or disconnected.
    accountId { ObjectID } The id of the account generating the event.
1
{
2
type: 'participant',
3
name: 'connected',
4
order: 1,
5
roomId: '5df02d890535377c38cfdeef',
6
status: 'connected',
7
accountId: '58c87b958b8f160100812b70'
8
}
Copied!

participant.after :: participant.disconnected - Participant left a room

    status { String } The current status of the participant generating this event - either connected or disconnected.
    accountId { ObjectID } The id of the account generating the event.
    duration { Number } The number of seconds the participant was connected to the room.
1
{
2
type: 'participant',
3
name: 'disconnected',
4
order: 8,
5
roomId: '5df02d890535377c38cfdeef',
6
status: 'disconnected',
7
accountId: '58c87b958b8f160100812b70',
8
duration: 101
9
}
Copied!

track.after :: track.added - Participant added a track

    status { String } The current status of the participant generating this event - either connected or disconnected.
    accountId { ObjectID } The id of the account generating the event.
    trackKind { String } The kind of track - data, audio or video.
    trackName { String } The track name. Currently unused and set to a uuid.
1
{
2
type: 'track',
3
name: 'added',
4
order: 2,
5
roomId: '5df02d890535377c38cfdeef',
6
status: 'connected',
7
accountId: '58c87b958b8f160100812b70',
8
trackKind: 'audio',
9
trackName: '613ef5df-cdee-4fd6-8f19-7140deb08b81'
10
}
Copied!

track.after :: track.removed - Participant removed a track

    status { String } The current status of the participant generating this event - either connected or disconnected.
    accountId { ObjectID } The id of the account generating the event.
    trackKind { String } The kind of track - data, audio or video.
    trackName { String } The track name. Currently unused and set to a uuid.
1
{
2
type: 'track',
3
name: 'removed',
4
order: 21,
5
roomId: '5df02d890535377c38cfdeef',
6
status: 'connected',
7
accountId: '58c87b958b8f160100812b70',
8
trackKind: 'video',
9
trackName: '8bd80b33-34ab-4ac6-b2fd-23d51cfe9156'
10
11
}
Copied!

track.after :: track.enabled - Participant un-paused a track

    status { String } The current status of the participant generating this event - either connected or disconnected.
    accountId { ObjectID } The id of the account generating the event.
    trackKind { String } The kind of track - data, audio or video.
    trackName { String } The track name. Currently unused and set to a uuid.
1
{
2
type: 'track',
3
name: 'enabled',
4
order: 22,
5
roomId: '5df02d890535377c38cfdeef',
6
status: 'connected',
7
accountId: '58c87b958b8f160100812b70',
8
trackKind: 'video',
9
trackName: '8bd80b33-34ab-4ac6-b2fd-23d51cfe9156'
10
11
}
Copied!

track.after :: track.disabled - Participant paused a track

    status { String } The current status of the participant generating this event - either connected or disconnected.
    accountId { ObjectID } The id of the account generating the event.
    trackKind { String } The kind of track - data, audio or video.
    trackName { String } The track name. Currently unused and set to a uuid.
1
{
2
type: 'track',
3
name: 'enabled',
4
order: 21,
5
roomId: '5df02d890535377c38cfdeef',
6
status: 'connected',
7
accountId: '58c87b958b8f160100812b70',
8
trackKind: 'video',
9
trackName: '8bd80b33-34ab-4ac6-b2fd-23d51cfe9156'
10
11
}
Copied!

Configuring Access

The Room definition defaultAcl is owner.delete and there is no createAcl defined for Rooms; Rooms must be created in-script using bypassCreateAcl().
Alternatively, the Room definition may be extended with overriding createAcl, defaultAcl and - incidentally - custom properties.
1
org.objects.objects.insertOne({
2
label: 'Room',
3
name: 'room',
4
createAcl: 'account.public', // any user can create rooms.
5
properties: [{
6
name: 'c_ustom',
7
label: 'Custom',
8
type: 'String'
9
}]
10
})
Copied!
Access to instances is provided using explicit acl writing. the shorthand import/export format can be used as well as the standard type, target, allow properties. Anyone with read access to the room instance is provided a token when reading the token property. For example:
1
org.objects.rooms.insertOne({
2
acl: [
3
'account.public.read', // any logged in account
4
'account.anonymous.read', // anyone anywhere
5
'role.developer.read', // developer role
6
`account.${emailToId('[email protected]')}.read`, // specific account (by id)
7
{ type: 1, target: emailToId('[email protected]'), allow: 4 } // long form
8
]
9
})
10
.bypassCreateAcl()
11
.execute()
12
13
function emailToId(email) {
14
return org.objects.accounts.readOne({ email }).skipAcl().grant('read').execute()._id
15
}
Copied!

Creating Rooms

Some environment-level options are required to create rooms.
    org.configuration.televisit.roomsEnabled must be true in order to create rooms in an environment.
    org.configuration.televisit.maxConcurrentRooms determines how many open rooms are allowed in a given environment.
To see current values for the above read current environment as an administrator (return org.read('configuration.televisit'))
To create a room instance, write an acl and insert a room instance:
1
return org.objects.rooms.insertOne({
2
acl: [
3
`role.developer.read` // example.
4
]
5
}).lean(false).execute()
Copied!
The Cortex room instance is now created and the state is "new". The provider room to which clients connect is opened asynchronously. Once this process has completed, the room's state property will be set to "open" and fire any room.after script triggers ({type: 'room', name: 'created', ...}).
Participant may now use their tokens to connect to the remote room.

Participant Status

Current participant status is updated in the Room instance to reflect the state of connected participants as they connect, disconnect, add and pause tracks, etc. Participant status is updated prior to script triggers so the latest is available in room event triggers.
Example participants list where both are connected and streaming audio and video.
1
const doc = org.objects.room
2
.readOne('5df2cb2a020fd46a6351e66b')
3
.paths('participants.status', 'participants.audio', 'participants.video', 'participants.account.name')
4
.execute()
5
6
let json = {
7
"_id": "5df2cb2a020fd46a6351e66b",
8
"object": "room",
9
"participants": [
10
{
11
"_id": "5df2cb3d020fd46a6351e70b",
12
"account": {
13
"_id": "58c87b958b8f160100812b70",
14
"name": {
15
"additional": [],
16
"first": "Jane",
17
"last": "Doe"
18
},
19
"object": "account"
20
},
21
"audio": [
22
"connected"
23
],
24
"status": "connected",
25
"video": [
26
"connected"
27
]
28
},
29
{
30
"_id": "5df2cce5020fd46a6351ef86",
31
"account": {
32
"_id": "5da9ff0fff5c5eb553a557f1",
33
"name": {
34
"additional": [],
35
"first": "John",
36
"last": "Doe"
37
},
38
"object": "account"
39
},
40
"audio": [
41
"connected"
42
],
43
"status": "connected",
44
"video": [
45
"connected"
46
]
47
}
48
]
49
}
Copied!
    The status of the participant is connected when they are connected to the room.
    The audio and video are arrays that contain connected and/or paused.
      When either of these tracks are removed, connected will no longer appear in the array, but paused may linger and
      should be ignored.
    When a participant status is disconnected:
      Ignore the values inaudio and video.
      The participant remains in the list.
Last modified 26d ago