/// <summary> /// socket UDP协议异步接收消息触发事件 /// </summary> /// <param name="ar"></param> private void ReceiveDataAsync(IAsyncResult ar) { int readLength = socket.EndReceiveFrom(ar, ref receveIP); Recevier?.Invoke(receiveBuffer, receveIP); Array.Clear(receiveBuffer, 0, receiveBuffer.Length); socket.BeginReceiveFrom(receiveBuffer, 0, receiveBuffer.Length, SocketFlags.None, ref receveIP, ReceiveDataAsync, null); //接收完消息后再次进行接收 }
public OpenCommand(Recevier recevier) { _recevier = recevier; }
public OtherCommand(Recevier recevier) { _reciever = recevier; }