using System.Collections.Generic; using Newtonsoft.Json; using LeanCloud.Realtime.Protocol; using LeanCloud.Storage.Internal; namespace LeanCloud.Realtime { public abstract class LCIMTypedMessage : LCIMMessage { protected LCIMTypedMessage() { } internal virtual int MessageType { get; private set; } internal virtual Dictionary Encode() { return new Dictionary { { "_lctype", MessageType } }; } internal override void Decode(DirectCommand direct) { base.Decode(direct); Dictionary msgData = JsonConvert.DeserializeObject>(direct.Msg, new LCJsonConverter()); DecodeMessageData(msgData); } protected virtual void DecodeMessageData(Dictionary msgData) { MessageType = (int)msgData["_lctype"]; } } }