Beispiel #1
0
        public void HangUp()
        {
            var callingUser = UserConnection.Get(Context.ConnectionId);

            if (callingUser == null)
            {
                return;
            }
            UserConnection.Remove(callingUser);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
            }
        }
Beispiel #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)
            {
            }
        }
Beispiel #7
0
        public UserConnection SaveMyInfo(Guid userId, string connectionId, string userName, string avatarPath)
        {
            var user = UserConnection.Get(userId, connectionId, userName, avatarPath);

            return(user);
        }
Beispiel #8
0
        public UserConnection GetUserByConnectionId(string connectionId)
        {
            var user = UserConnection.Get(connectionId);

            return(user);
        }
Beispiel #9
0
        public UserConnection GetUserById(Guid userId)
        {
            var users = UserConnection.Get(userId);

            return(users?[0]);
        }