public void HangUp() { var callingUser = UserConnection.Get(Context.ConnectionId); if (callingUser == null) { return; } UserConnection.Remove(callingUser); }
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); }
// 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); }
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); } }
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) { } }
public UserConnection SaveMyInfo(Guid userId, string connectionId, string userName, string avatarPath) { var user = UserConnection.Get(userId, connectionId, userName, avatarPath); return(user); }
public UserConnection GetUserByConnectionId(string connectionId) { var user = UserConnection.Get(connectionId); return(user); }
public UserConnection GetUserById(Guid userId) { var users = UserConnection.Get(userId); return(users?[0]); }