Esempio n. 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);
        }
Esempio n. 2
0
 public SessionMessageBase()
 {
     Header = new SessionMessageHeader()
     {
         SessionMessageType = SessionMessageTypeAttribute.GetMessageTypeForType(GetType()),
         Version            = 2
     };
 }
Esempio n. 3
0
        public static SessionMessageBase CreateFromMessageType(SessionMessageType messageType)
        {
            var type = SessionMessageTypeAttribute.GetTypeForMessageType(messageType);

            if (type == null)
            {
                return(new UnknownMessage());
            }

            return((SessionMessageBase)Activator.CreateInstance(type));
        }