コード例 #1
0
        static async void Send(SimpleKcpClient client, string v)
        {
            var buffer = System.Text.Encoding.UTF8.GetBytes(v);

            client.SendAsync(buffer, buffer.Length);
            var resp = await client.ReceiveAsync();

            var respstr = System.Text.Encoding.UTF8.GetString(resp);

            Console.WriteLine($"收到服务器回复:    {respstr}");
        }
コード例 #2
0
        static async void StartRecv(SimpleKcpClient client)
        {
            var res = await client.ReceiveAsync();

            StartRecv(client);

            await Task.Delay(1);

            var str = System.Text.Encoding.UTF8.GetString(res);

            if ("发送一条消息" == str)
            {
                Console.WriteLine(str);

                var buffer = System.Text.Encoding.UTF8.GetBytes("回复一条消息");
                client.SendAsync(buffer, buffer.Length);
            }
        }