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.SessionMessageType = fragment.Header.SessionMessageType; message.Header.Version = fragment.Header.Version; message.Deserialize(new BEReader(fragment.Fragment)); return(message); }
public SessionMessageBase() { Header = new SessionMessageHeader() { SessionMessageType = SessionMessageTypeAttribute.GetMessageTypeForType(GetType()), Version = 2 }; }
public static SessionMessageBase CreateFromMessageType(SessionMessageType messageType) { var type = SessionMessageTypeAttribute.GetTypeForMessageType(messageType); if (type == null) { return(new UnknownMessage()); } return((SessionMessageBase)Activator.CreateInstance(type)); }