Beispiel #1
0
        private SessionMessageBase DeserializeMessage(SessionFragmentMessage fragment)
        {
            var type = SessionMessageTypeAttribute.GetTypeForMessageType(fragment.Header.SessionMessageType);

            if (type == null)
            {
                logger.LogTrace("Incoming decrypted has no impl: " +
                                JsonConvert.SerializeObject(fragment, Formatting.Indented));
            }

            var message = CreateFromMessageType(fragment.Header.SessionMessageType);

            if (fragment.Header.IsFragment)
            {
                message = new FragmentMessage();
            }

            logger.LogTrace($"Received {message.GetType().Name} message");

            message.Header.ChannelId          = fragment.Header.ChannelId;
            message.Header.RequestAcknowledge = fragment.Header.RequestAcknowledge;
            message.Header.IsFragment         = fragment.Header.IsFragment;
            message.Header.SessionMessageType = fragment.Header.SessionMessageType;
            message.Header.Version            = fragment.Header.Version;

            message.Deserialize(new BEReader(fragment.Fragment));

            return(message);
        }
Beispiel #2
0
        private Task SendFragmentAsync(SessionMessageBase message, uint sequenceNumber)
        {
            var fragment = new SessionFragmentMessage();

            fragment.Header.ChannelId          = message.Header.ChannelId;
            fragment.Header.RequestAcknowledge = message.Header.RequestAcknowledge;
            fragment.Header.SessionMessageType = message.Header.SessionMessageType;
            fragment.Header.Version            = message.Header.Version;

            fragment.Header.SequenceNumber      = sequenceNumber;
            fragment.Header.SourceParticipantId = _participantId;

            var writer = new EndianWriter();

            message.Serialize(writer);
            fragment.Fragment = writer.ToBytes();

            return(_transport.SendAsync(fragment));
        }