internal void MockConnect() { _kcpChannel = new KcpChannel(Conv); _kcpChannel.MessageReceived += (d) => { OnDataReceived(d); }; _kcpChannel.ProcessPost += (d) => { Server.SendMessageByUnicast(d.ToArray(), EndPoint); }; _kcpChannel.Closed += OnClose; _kcpChannel.Run(); }
public void Connect(string ip, int port) { _socket = new UdpClient(); _kcpChannel = new KcpChannel(Conv); _kcpChannel.MessageReceived += (d) => { OnMessageReceived?.Invoke(this, d); }; _kcpChannel.ProcessPost += (d) => { _socket.Send(d.ToArray(), d.Length); }; _kcpChannel.Run(); _socket.Connect(ip, port); //_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //_socket.Bind(IPEndPoint.); //Thread t = new Thread(sendMsg); //t.Start(); _ = ReciveMsgAsync(); }