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); } }
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); } }
public void SendData(byte[] ar) { #if UNITY_EDITOR && !UNITY_EDITOR_OSX udpsocket.Send(ar); #else _SendData(ref ar[0], ar.Length); #endif }