public SessionClientWrapper TryGetSessionClientByIP(string ip) { var ipPont = Helper.TryParseStringToIp(ip); if (ipPont == null) { return(null); } if (!OCServerToDiscrord.TryGetValue(ipPont, out ulong discordID)) { return(null); } DiscrordToOCServer.TryGetValue(discordID, out SessionClientWrapper result); return(result); }
internal bool RegisterNewServer(Chanel2Server server, SessionClientWrapper sessionClient) { var apadr = IPAddress.Parse(server.IP); var endPoint = new IPEndPoint(apadr, server.Port); var result = OCServerToDiscrord.TryAdd(endPoint, server.Id) && UserOnServers.TryAdd(server.Id, new ConcurrentDictionary <ulong, OCUser>()); result &= DiscrordToOCServer.TryAdd(server.Id, sessionClient); // if sessionClient.IsLogined then must be registred in DataBase if (sessionClient.IsLogined) { result &= _repositoryChanel2Server.AddNewItem(server); } else { result &= sessionClient.ConnectAndLogin(); } return(result); }