public void Update() { var cid = Context.ConnectionId; var users = LCU.Get(); foreach (var u in users) { var usersIgnore = users.Where(x => !x.Key.Equals(u.Key)); Clients.Client(u.Key).UpdateList(usersIgnore); } }
public void GuestSend(string name, string msg) { var cid = Context.ConnectionId; var users = LCU.Get(); var cuser = new User(); if (users.TryGetValue(cid, out cuser)) { cuser.UserName = name; cuser.FullName = name; users[cid] = cuser; } foreach (var u in users.Where(x => !x.Key.Equals(cid))) { SendPrivate(u.Value.Id, msg); } }
public void SendPrivate(string toUserId, string msg) { var cid = Context.ConnectionId; var users = LCU.Get(); var cuser = new User(); users.TryGetValue(cid, out cuser); var touser = users.Where(x => x.Value.Id.Equals(toUserId)); if (touser != null) { Clients.Client(touser.FirstOrDefault().Key).Received(cuser, msg); } else { Clients.Caller.Received(touser.FirstOrDefault().Key, "System: User is Offline"); } }