Пример #1
0
        public async Task JoinGroupCall(string message)
        {
            try
            {
                JObject objMessage           = JObject.Parse(message);
                int     RoomId               = (int)objMessage["RoomId"];
                int     ParticipantId        = (int)objMessage["ParticipantId"];
                string  Role                 = (string)objMessage["Role"];
                int     AppointmentId        = (int)objMessage["AppointmentId"];
                int     CurrentAppointmentId = (int)objMessage["CurrentAppointmentId"];
                var     participant          = await _commonManager.GetParticipantDetailsById(new CallParticipantModel
                {
                    RoomId        = RoomId,
                    ParticipantId = ParticipantId,
                    Role          = Role,
                    AppointmentId = AppointmentId
                });

                var    tokBoxSetting = ConfigurationManager.AppSetting.TokBoxVideoSetting;
                var    OT            = new OpenTok(tokBoxSetting.APIKEY, tokBoxSetting.APISecret);
                string token         = OT.GenerateToken((string)objMessage["SessionId"]);
                await Clients.Client(participant.SocketId).SendAsync("JoinGroupCall", new JObject
                {
                    ["SessionId"]     = objMessage["SessionId"],
                    ["AccessToken"]   = token,
                    ["AppointmentId"] = CurrentAppointmentId,
                    ["ParticipantId"] = ParticipantId,
                    ["RoomId"]        = RoomId
                }.ToString());
            }
            catch (Exception ex)
            {
                await Clients.Caller.SendAsync("Exception", new JObject
                {
                    ["error"]      = ex.Message,
                    ["stackTrace"] = ex.StackTrace
                }.ToString());
            }
        }