Ejemplo n.º 1
0
        public void HangUp()
        {
            var callingUser = UserConnection.Get(Context.ConnectionId);

            if (callingUser == null)
            {
                return;
            }
            UserConnection.Remove(callingUser);
        }
Ejemplo n.º 2
0
        public async Task CallRequest(Guid userId, CallType callType)
        {
            var caller    = UserConnection.Get(this.GetConnectionId());
            var receivers = UserConnection.Get(userId);

            if (caller == null || receivers == null)
            {
                Console.WriteLine("Caller null || receiver null");
            }
            await this.Clients.Clients(receivers.Select(x => x.ConnectionId).ToList()).SendAsync("callRequest", caller, callType);

            //await this.Clients.Clients(receiver.ConnectionId).SendAsync("callRequest", caller, callType);
        }
Ejemplo n.º 3
0
        // WebRTC Signal Handler
        public async Task SendSignal(string data, Guid userId)
        {
            var receivers = UserConnection.Get(userId);

            // Make sure receivers are valid
            if (receivers == null)
            {
                return;
            }

            // These folks are in a call together, let's let em talk WebRTC
            await Clients.Clients(receivers.Select(x => x.ConnectionId).ToList()).SendAsync("receiveSignal", data);
        }
Ejemplo n.º 4
0
        public async Task CallAccept(Guid userId)
        {
            var users = UserConnection.Get(userId);

            try
            {
                await this.Clients.Clients(users.Select(x => x.ConnectionId).ToList()).SendAsync("callStatus", CallStatus.Accept);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        private async Task SendMessage(Guid senderId, Guid receiverId, ChatResponse messageResponse)
        {
            var sender   = UserConnection.Get(senderId);
            var receiver = UserConnection.Get(receiverId);

            if (receiver == null)
            {
                await _hub.Clients.Clients(sender.Select(x => x.ConnectionId).ToList()).SendAsync("messageResponse", messageResponse);
            }
            else
            {
                await _hub.Clients.Clients(sender.Select(x => x.ConnectionId).ToList().Concat(receiver.Select(x => x.ConnectionId).ToList()).ToList()).SendAsync("messageResponse", messageResponse);
            }
        }
Ejemplo n.º 6
0
        public async Task SendNotification(NotificationResponse notification)
        {
            var receiver = UserConnection.Get(notification.ToId);

            if (receiver == null)
            {
                return;
            }

            try
            {
                await _hub.Clients.Clients(receiver.Select(x => x.ConnectionId).ToList()).SendAsync("notification", notification);
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 7
0
        public UserConnection SaveMyInfo(Guid userId, string connectionId, string userName, string avatarPath)
        {
            var user = UserConnection.Get(userId, connectionId, userName, avatarPath);

            return(user);
        }
Ejemplo n.º 8
0
        public UserConnection GetUserByConnectionId(string connectionId)
        {
            var user = UserConnection.Get(connectionId);

            return(user);
        }
Ejemplo n.º 9
0
        public UserConnection GetUserById(Guid userId)
        {
            var users = UserConnection.Get(userId);

            return(users?[0]);
        }