Exemple #1
0
        public KcpHostClient(ChannelConfig channelConfig, IPEndPoint remoteAddress)
        {
            if (client == null)
            {
                client = KcpClient.Instance;
                client.init(channelConfig);
            }

            this._ukcp = client.connect(remoteAddress, channelConfig, this);
        }
Exemple #2
0
        public KcpHostClient(ChannelConfig channelConfig, IPEndPoint remoteAddress)
        {
            if (client == null)
            {
                lock (lockObj)
                {
                    if (client == null)
                    {
                        client = new KcpClient();
                        client.init(channelConfig);
                    }
                }
            }

            this._ukcp = client.connect(remoteAddress, channelConfig, this);
        }
        public static void start()
        {
            ChannelConfig channelConfig = new ChannelConfig();

            channelConfig.initNodelay(true, 40, 2, true);
            channelConfig.Sndwnd              = 512;
            channelConfig.Rcvwnd              = 512;
            channelConfig.Mtu                 = 512;
            channelConfig.FecDataShardCount   = 3;
            channelConfig.FecParityShardCount = 1;
            channelConfig.AckNoDelay          = true;
            channelConfig.Crc32Check          = true;
            channelConfig.Conv                = 55;
            //channelConfig.setTimeoutMillis(10000);

            KcpClient kcpClient = new KcpClient();

            kcpClient.init(channelConfig);

            KcpRttExampleClient kcpClientRttExample = new KcpRttExampleClient();
            //kcpClient.connect(new InetSocketAddress("127.0.0.1",20003),channelConfig,kcpClientRttExample);

            EndPoint remoteAddress = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 20003);

            _ukcp = kcpClient.connect(remoteAddress, channelConfig, kcpClientRttExample);

            try
            {
                kcpClientRttExample.init();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }