private void Task_OnReceiveCompleted(int numBytesRead, Client registrant) { // Build back our MessageReader var reader = new BufferValueReader(registrant.Buffer); var message = new Message(); message.ReadPayload(reader); reader.Position = 0; Console.WriteLine(String.Format("Received a {0} byte {1}Message from {2}.", numBytesRead, message.MessageType, registrant.Socket.RemoteEndPoint)); if (OnMessageReceived != null) { OnMessageReceived(this, new MessageReceivedEventArgs() { From = (IPEndPoint)registrant.RemoteEndPoint, MessageReader = reader, MessageType = message.MessageType }); } }
private void Task_OnReceiveCompleted(int numBytesRead) { // Build back our MessageReader var reader = new BufferValueReader(Buffer); var message = new Message(); message.ReadPayload(reader); reader.Position = 0; Console.WriteLine(String.Format("Received a {0} byte {1}Message from {2}.", numBytesRead, message.MessageType, Socket.RemoteEndPoint)); if (OnMessageReceived != null) OnMessageReceived(this, new MessageReceivedEventArgs() { From = (IPEndPoint) Socket.RemoteEndPoint, MessageReader = reader, MessageType = message.MessageType }); }