Esempio n. 1
0
        public async Task <VideoChatConfiguration> StartMeeting(Guid meetingId)
        {
            var meeting = MeetingInfoRepository.GetMeetingInfo(meetingId);

            if (meeting == null)
            {
                return(null);
            }
            if (meeting.HasAgent)
            {
                return(null);
            }
            if (meeting.HasMeetingStarted)
            {
                return(null);
            }


            var room = meetingId.ToString();

            Debug.WriteLine("Starting meeting {0} by agent {1}", new object[] { room, Context.ConnectionId });
            var config = new VideoChatConfiguration
            {
                AppId              = 416,
                ApiKey             = "<insert ADL key here>",
                ScopeId            = room,
                MaxWidth           = 240,
                MaxHeight          = 320,
                MaxFramesPerSecond = 15,
                MaxBitRate         = 1024,
                Expires            = VideoChatConfiguration.CurrentTimeMillis() + (5 * 60),
                MeetingId          = meetingId
            };

            config.Salt = config.ScopeId;

            meeting.ConnectAgent(Context.ConnectionId);
            meeting.StartMeeting(config);

            // add caller to meeting room
            await GroupManager.AddToGroup(Groups, room, Context.ConnectionId);

            if (meeting.HasClient)
            {
                // fire off the joined message to the agent as the client is already waiting in the room
                try
                {
                    Debug.WriteLine("Meeting {0} has client, sending client joined to agent", new object[] { room });

                    Clients.Caller.clientJoined();
                }
                catch (Exception)
                {
                    Debug.WriteLine("Error calling clientJoined");
                }
                // Tell the client to start with the following config
                try
                {
                    Debug.WriteLine("Meeting {0} has client, sending start meeting to client {1}", new object[] { room, meeting.ClientConnectionId });
                    Clients.Group(room, Context.ConnectionId).startMeeting(config);
                }
                catch (Exception)
                {
                    Debug.WriteLine("Error calling startMeeting");
                }
            }

            UpdateMeetingStatusToClients(this);
            return(config);
        }