コード例 #1
0
 internal ServerListCallback(CMsgClientServerList serverList)
 {
     Servers = serverList.servers
               .Select(s => new { Type = ( EServerType )s.server_type, EndPoint = new IPEndPoint(NetHelpers.GetIPAddress(s.server_ip), ( int )s.server_port) })
               .GroupBy(s => s.Type)
               .ToDictionary(grp => grp.Key, grp => new ReadOnlyCollection <IPEndPoint>(grp.Select(s => s.EndPoint).ToList()));
 }
コード例 #2
0
        private Task ReceiveServerList(CMsgClientServerList list)
        {
            foreach (var server in list.servers)
            {
                var    type        = (ServerType)server.server_type;
                Server serverValue = new Server(server.server_ip.ToIPAddress(), (int)server.server_port);
                if (_servers.ContainsKey(type))
                {
                    _servers[type] = _servers[type].Add(serverValue);
                }
                else
                {
                    _servers[type] = ImmutableHashSet.Create(serverValue);
                }
            }

            return(Task.CompletedTask);
        }