Exemple #1
0
    static void test_v2(string host, UInt16 port)
    {
        var wait_response = true;

        KcpProject.v2.UdpSocket client = null;

        // 创建一个实例
        client = new KcpProject.v2.UdpSocket((byte[] buf) =>
        {
            wait_response = false;
            Console.WriteLine("recv message: {0}", System.Text.ASCIIEncoding.ASCII.GetString(buf));
        });

        // 绑定端口
        client.Connect(host, port);

        // 发送消息
        client.Send("Hello");

        // update.
        while (wait_response)
        {
            client.Update();
            System.Threading.Thread.Sleep(100000000);
        }
    }
Exemple #2
0
    static void test_v2(string host, UInt16 port)
    {
        var wait_response = true;

        KcpProject.v2.UdpSocket client = null;

        // 创建一个实例
        client = new KcpProject.v2.UdpSocket((byte[] buf) =>
        {
            wait_response = false;
            Console.WriteLine("recv message: {0}", System.Text.ASCIIEncoding.ASCII.GetString(buf));
        });

        // 绑定端口
        client.Connect(host, port);

        // 发送消息
        client.Send("Hello KCP.");

        // update.
        while (wait_response)
        {
            client.Update();
            System.Threading.Thread.Sleep(10);
        }
    }
Exemple #3
0
    KcpProject.v2.UdpSocket udpsocket;    //

    public bool InitKcp(string ip, short port)
    {
#if UNITY_EDITOR && !UNITY_EDITOR_OSX
        udpsocket = new KcpProject.v2.UdpSocket();
        udpsocket.Connect(ip, (ushort)port);
        return(true);
#else
        return(_InitKcp(ip, port, 1400, 128, 0, 0, false));//enable fec by: _InitKcp(ip, port, 1400, 128, 2, 2, false);
#endif
    }