public void can_serialize_from_message() { var tcpMsg = new TcpMessage(_testEvent); var tcpmsg2 = TcpMessage.FromArraySegment(tcpMsg.Data); Assert.IsType <WoftamEvent>(tcpmsg2.WrappedMessage); var msg2 = tcpmsg2.WrappedMessage as WoftamEvent; Assert.NotNull(msg2); // ReSharper disable once PossibleNullReferenceException Assert.Equal(_testEvent.Property1, msg2.Property1); Assert.Equal(_testEvent.Property1, ((WoftamEvent)tcpmsg2.WrappedMessage).Property1); }
protected void TcpMessageArrived(ArraySegment <byte> obj) { TcpMessage tcpMessage; try { tcpMessage = TcpMessage.FromArraySegment(obj); } catch (Exception ex) { Log.ErrorException(ex, "TcpMessage.FromArraySegment() threw an exception:"); throw; } Type type = MessageHierarchy.GetMsgType(tcpMessage.WrappedMessage.MsgTypeId); Log.Trace("Message " + tcpMessage.WrappedMessage.MsgId + " (Type " + type.Name + ") received from TCP."); if (_inboundSpamMessageTypes.Contains(type)) { if (_inboundSpamMessageQueuedHandler == null) { Log.Error("TCP message (a Message) has arrived, but _inboundSpamMessageQueuedHandler is null."); return; } _inboundSpamMessageQueuedHandler.Publish(tcpMessage.WrappedMessage); } else { if (_inboundMessageQueuedHandler == null) { Log.Error("TCP message (a Message) has arrived, but _inboundMessageQueuedHandler is null."); return; } _inboundMessageQueuedHandler.Publish(tcpMessage.WrappedMessage); } }