* LCIMTextMessage.cs:

* LCIMTypedMessage.cs: chore: 调整消息数据保存
oneRain 2020-04-27 18:19:15 +08:00
parent aa832f4cb5
commit c66ce32f9a
2 changed files with 5 additions and 5 deletions

View File

@ -30,7 +30,6 @@ namespace LeanCloud.Realtime {
public override int MessageType => TextMessageType;
internal override void Decode(Dictionary<string, object> msgData) {
base.Decode(msgData);
if (msgData.TryGetValue(MessageTextKey, out object value)) {
Text = value as string;
}

View File

@ -109,11 +109,8 @@ namespace LeanCloud.Realtime {
}
internal virtual void Decode(Dictionary<string, object> msgData) {
// 直接保存
data = msgData;
MessageType = (int)msgData[MessageTypeKey];
if (msgData.TryGetValue(MessageAttributesKey, out object attrObj)) {
customProperties = LCDecoder.Decode(attrObj) as Dictionary<string, object>;
}
}
internal static LCIMTypedMessage Deserialize(string json) {
@ -128,6 +125,10 @@ namespace LeanCloud.Realtime {
// 未注册的类型消息
message = new LCIMTypedMessage();
}
message.MessageType = msgType;
if (msgData.TryGetValue(MessageAttributesKey, out object attrObj)) {
message.customProperties = LCDecoder.Decode(attrObj) as Dictionary<string, object>;
}
message.Decode(msgData);
return message;
}