Ejemplo n.º 1
0
        public void TestGoogle()
        {
            var endpoint = HostResolver.Resolve(GOOGLE, 80);

            Assert.NotNull(endpoint);
            Assert.False(string.IsNullOrEmpty(endpoint.ToString()));
        }
Ejemplo n.º 2
0
        public void TestLocalIPv6()
        {
            var endpoint = HostResolver.Resolve(LOCAL_IPV6, PORT);

            Assert.NotNull(endpoint);
            Assert.AreEqual($"[::]:{PORT}", endpoint.ToString());
        }
Ejemplo n.º 3
0
        public void TestLocalhost()
        {
            var endpoint = HostResolver.Resolve(LOCAL_HOST, PORT);

            Assert.NotNull(endpoint);
            Assert.AreEqual($"{LOCAL_IPV4}:{PORT}", endpoint.ToString());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Add a server to the list of servers
        /// </summary>
        /// <param name="address"></param>
        /// <param name="port"></param>
        private void AddServer(string address, ushort port = NetWorker.DEFAULT_PORT, bool isLocal = true)
        {
            var hostAndPort = $"{address}:{port}";

            for (int i = 0; i < serverList.Count; ++i)
            {
                var server = serverList[i];
                if (server.Hostname == hostAndPort)
                {
                    // Already have that server listed nothing else to do
                    return;
                }
            }

            var serverListItemData = new ServerListItemData {
                ListItem = GameObject.Instantiate <ServerListEntry>(serverListEntryTemplate, servers.content),
                Hostname = hostAndPort,
                IsLocal  = isLocal
            };

            serverListItemData.ListItem.gameObject.SetActive(true);

            var endpoint = HostResolver.Resolve(address, Settings.SQPPort);

            serverListItemData.SqpQuery = sqpClient.GetQuery(endpoint);

            UpdateItem(serverListItemData);
            serverListItemData.NextUpdate = Time.time + 5.0f + UnityEngine.Random.Range(0.0f, 1.0f);

            serverList.Add(serverListItemData);
            SetListItemSelected(serverListItemData, false);

            RepositionItems();
        }
Ejemplo n.º 5
0
        private static TcpClient InitClient(string host, int port)
        {
            var endpoint = new IPEndPoint(HostResolver.Resolve(host), port);
            var client   = new TcpClient();

            client.Connect(endpoint);
            log.Debug(() => "TCP client for graphite initialized for " + host + ":" + port.ToString());
            return(client);
        }