Esempio n. 1
0
        private void OnTransportMessageReceived(TransportMessage transportMessage)
        {
            if (_replayMessageTypeIds.Contains(transportMessage.MessageTypeId))
            {
                var replayEvent = (IReplayEvent)_serializer.ToMessage(transportMessage);
                if (replayEvent.ReplayId == _currentReplayId)
                {
                    _phase.OnReplayEvent(replayEvent);
                }

                return;
            }

            if (transportMessage.MessageTypeId == MessageTypeId.PersistenceStopping)
            {
                _persistenceIsDown = true;

                var ackMessage = TransportMessage.Infrastructure(MessageTypeId.PersistenceStoppingAck, _innerTransport.PeerId, _innerTransport.InboundEndPoint);

                _logger.InfoFormat("Sending PersistenceStoppingAck to {0}", transportMessage.Originator.SenderId);
                _innerTransport.Send(ackMessage, new[] { new Peer(transportMessage.Originator.SenderId, transportMessage.Originator.SenderEndPoint) }, new SendContext());

                return;
            }

            if (transportMessage.MessageTypeId.IsInfrastructure())
            {
                TriggerMessageReceived(transportMessage);
            }
            else
            {
                _phase.OnRealTimeMessage(transportMessage);
            }
        }
Esempio n. 2
0
 private IMessage ToMessage(MessageTypeId messageTypeId, Stream messageStream, TransportMessage transportMessage)
 {
     try
     {
         return(_serializer.ToMessage(transportMessage, messageTypeId, messageStream));
     }
     catch (Exception exception)
     {
         HandleDeserializationError(messageTypeId, messageStream, transportMessage.Originator, exception, transportMessage);
     }
     return(null);
 }
Esempio n. 3
0
 private IMessage ToMessage(MessageTypeId messageTypeId, byte[] messageStream, TransportMessage transportMessage)
 {
     return(_serializer.ToMessage(transportMessage));
 }