public void NewMessage(string msgMarkup) { ChatUser chatClient = DBSupport.GetUser(new ChatUser { ConnectionId = Context.ConnectionId }); string[] exceptUsers = null; if (chatClient == null) { string username = Context.RequestCookies["FunkyUser"].Value.Substring(0, Context.RequestCookies["FunkyUser"].Value.IndexOf('&')); username = username.Substring(username.IndexOf('=') + 1); chatClient = DBSupport.GetUser(new ChatUser { Username = username }); exceptUsers = SharedSupport.ExceptUsers(chatClient); exceptUsers = exceptUsers.Concat(new string[] { Context.ConnectionId }).ToArray(); exceptUsers = exceptUsers.ToList().Where(x => !x.Equals(chatClient.ConnectionId)).ToArray(); } else { exceptUsers = SharedSupport.ExceptUsers(chatClient); } //For updating context user connect time DBSupport.UpdateUser(chatClient); Clients.AllExcept(exceptUsers).newUserMessage(msgMarkup); }
public void JoinedOnReconnected(ChatUser user) { if (DBSupport.IsIdExist(user.Id)) { DBSupport.UpdateUser(user); } }
public void NewUserJoining(ChatUser user) { if (DBSupport.IsIdExist(user.Id)) { DBSupport.UpdateUser(user); } else { DBSupport.AddNewUser(user); } Clients.Others.newUserJoined(user); Clients.Caller.youJoined(DBSupport.GetAllUsers()); Clients.All.totalUsers(DBSupport.GetUsersCount()); }
public void NewPrivateMessage(string msgMarkup, string username) { if (DBSupport.GetUser(new ChatUser { Username = username }) == null) { return; } ChatUser pvtChatClient = DBSupport.GetUser(new ChatUser { ConnectionId = Context.ConnectionId }); ChatUser pvtChatRecipent = DBSupport.GetUser(new ChatUser { Username = username }); //For updating context user connect time DBSupport.UpdateUser(pvtChatClient); if (!pvtChatClient.Blocks.Contains(pvtChatRecipent.Username) && !pvtChatRecipent.Blocks.Contains(pvtChatClient.Username)) { Clients.Client(pvtChatRecipent.ConnectionId).newUserPrivateMessage(msgMarkup, pvtChatClient.Username); } }