public ConSolUser CreateUserConSol(IWebSocketConnection context, string name, Func <string, IWebSocketConnection, int> sendMessageFunc) { if (OnlineUsersByName.ContainsKey(name)) { return(OnlineUsersByName[name]); } else { ConSolUser user = new ConSolUser(context, name, Logs, sendMessageFunc); OnlineUsersByName.TryAdd(name, user); OnlineUsersByContext.TryAdd(context, user); return(user); } }
public ConSolUser RemoveUserConSol(IWebSocketConnection context) { try { if (OnlineUsersByContext.ContainsKey(context)) { ConSolUser user = OnlineUsersByContext[context]; OnlineUsersByContext.TryRemove(context, out user); OnlineUsersByName.TryRemove(user.Name, out user); return(user); } } catch (Exception ex) { WriteLine(ex.Message); WriteLine(ex.StackTrace); } return(null); }