示例#1
0
        private bool Bootstrap(ToxConfigNode node)
        {
            var  toxNode = new ToxNode(node.Address, node.Port, new ToxKey(ToxKeyType.Public, node.PublicKey));
            var  error   = ToxErrorBootstrap.Ok;
            bool success = _tox.Bootstrap(toxNode, out error);

            if (success)
            {
                Debugging.Write(string.Format("Bootstrapped off of {0}:{1}", node.Address, node.Port));
            }
            else
            {
                Debugging.Write(string.Format("Could not bootstrap off of {0}:{1}, error: {2}", node.Address, node.Port, error));
            }

            //even if adding the tcp relay fails for some reason (while it shouldn't...), we'll consider this successful.
            if (_tox.AddTcpRelay(toxNode, out error))
            {
                Debugging.Write(string.Format("Added TCP relay {0}:{1}", node.Address, node.Port));
            }
            else
            {
                Debugging.Write(string.Format("Could not add TCP relay {0}:{1}, error: {2}", node.Address, node.Port, error));
            }

            return(success);
        }
示例#2
0
        public void TestToxBootstrapAndConnectTcp()
        {
            var tox   = new Tox(new ToxOptions(true, false));
            var error = ToxErrorBootstrap.Ok;

            foreach (var node in Globals.TcpRelays)
            {
                bool result = tox.AddTcpRelay(node, out error);
                if (!result || error != ToxErrorBootstrap.Ok)
                {
                    Assert.Fail("Failed to bootstrap error: {0}, result: {1}", error, result);
                }
            }

            tox.Start();
            while (!tox.IsConnected)
            {
                Thread.Sleep(10);
            }

            Console.WriteLine("Tox connected!");
            tox.Dispose();
        }
示例#3
0
        public void TestToxProxySocks5()
        {
            var options = new ToxOptions(true, ToxProxyType.Socks5, "127.0.0.1", 9050);
            var tox     = new Tox(options);
            var error   = ToxErrorBootstrap.Ok;

            foreach (var node in Globals.TcpRelays)
            {
                bool result = tox.AddTcpRelay(node, out error);
                if (!result || error != ToxErrorBootstrap.Ok)
                {
                    Assert.Fail("Failed to bootstrap, error: {0}, result: {1}", error, result);
                }
            }

            tox.Start();
            while (!tox.IsConnected)
            {
                Thread.Sleep(10);
            }

            Console.WriteLine("Tox connected!");
            tox.Dispose();
        }