Connection to signaling

This article explains how to connect a client to signaling and join a room via VT API

To connect you need to know the values of the following fields from the user license:signaling_url,username,password - you can get them from the license file with those credentials.

chevron-rightJSON query example:hashtag
query
{
  "username": "[email protected]",  // username from license
  "auth": "{\"password\":\"qwerty\"}"     // password from license
}
chevron-rightC# code example:hashtag
public void Connect(string signaling, string room, string username, string password)
        {
            _room = room;

            SocketIO = new SocketIO(signaling.StartsWith("https") ? signaling : $"https://{signaling}");

            SocketIO.Options.Query = new Dictionary<string, string>
            {
                ["username"] = username,
                ["auth"] = $"{{\\"password\\":\\"{password}\\"}}",
            };
            Console.WriteLine($"--> query: {SocketIO.JsonSerializer.Serialize(new object[] { SocketIO.Options.Query }).Json}");

            SocketIO.OnError += (_, e) => OnError(e);
            SocketIO.OnConnected += (_, __) => Console.WriteLine("<-- connected");
            SocketIO.OnDisconnected += (_, __) => Console.WriteLine("<-- disconnected");
            SocketIO.OnAny(EventHandler);
            SocketIO.ConnectAsync();
        } 

You will need to handle the following events:

  • on_connection, you will need auth_id value from this event response.

  • on_join

  • on_leave

chevron-rightJSON on_connectionexample:hashtag
on_connection
[
  {
    "session_id": 1653558286392,
    "signaling_ver": "2.1",
    "remoteAddress": "::ffff:172.18.0.1",
    "remotePort": 38822,
    "headers": {...},
    "server_metadata": {...},
    "username": "[email protected]",
    "role": "owner",
    "auth_room": "Auth",
    "auth_id": "pol2b6VKbaSVbCyyAAIs"
  }
]
chevron-rightJSON on_join example:hashtag
on_join (first value - id of joined member)
[
  "EawLi6fQ9jKByY/R46TRSyVHsKY=",    // joined member id
  {
    "hardware_id": "{42CE8DCF-14EC-00DA-9625-91768E3ED46E}",
    "location": "US, Chicago",
    "mode": "enum",
    "name": "_VT_MNG_RCV_",
    "peerType": "cpp",
    "rcv_name": "VT_ReceiverMng",
    "vt_version": "1.9.4.966",
    "id": "WbaqzsMXqeQiwuoa",
    "private": {...},
    "join_props": {...}
  }
]
chevron-rightJSON on_join example:hashtag
chevron-rightC# code example:hashtag

Join room

To join the room you will need the room_id which is generated by the signaling after you send the auth_room_name_mask like in the following JSON request.

chevron-rightJSON request example:hashtag

In response, you will get the callback with the room_id.

chevron-rightJSON callback example:hashtag

C# Code example:

chevron-rightC# code example:hashtag

Now when you get room_id value you can join room:

chevron-rightJSON join example:hashtag
chevron-rightC# code example:hashtag

You will receive a callback with members field - a collection of managers in the room you’ve joined.

chevron-rightJSON callback example:hashtag

Optionally you can enumerate the managers with an individual request:

chevron-rightC# code example:hashtag

Right now you are prepared to work with managers.

Last updated