2020-03-18 16:21:29 +08:00
|
|
|
|
using System.Collections.Generic;
|
2020-03-12 16:23:21 +08:00
|
|
|
|
|
|
|
|
|
namespace LeanCloud.Realtime {
|
2020-04-27 17:44:14 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 文本消息
|
|
|
|
|
/// </summary>
|
2020-03-16 11:50:49 +08:00
|
|
|
|
public class LCIMTextMessage : LCIMTypedMessage {
|
2020-04-27 17:44:14 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 文本
|
|
|
|
|
/// </summary>
|
2020-03-17 16:17:19 +08:00
|
|
|
|
public string Text {
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
2020-03-16 11:50:49 +08:00
|
|
|
|
|
2020-03-18 16:21:29 +08:00
|
|
|
|
internal LCIMTextMessage() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LCIMTextMessage(string text) : base() {
|
2020-03-17 16:17:19 +08:00
|
|
|
|
Text = text;
|
2020-03-16 11:50:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-18 16:21:29 +08:00
|
|
|
|
internal override Dictionary<string, object> Encode() {
|
|
|
|
|
Dictionary<string, object> data = base.Encode();
|
|
|
|
|
if (!string.IsNullOrEmpty(Text)) {
|
2020-04-27 17:44:14 +08:00
|
|
|
|
data[MessageTextKey] = Text;
|
2020-03-18 16:21:29 +08:00
|
|
|
|
}
|
|
|
|
|
return data;
|
2020-03-17 16:17:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-27 17:44:14 +08:00
|
|
|
|
public override int MessageType => TextMessageType;
|
2020-03-27 17:46:45 +08:00
|
|
|
|
|
2020-04-27 17:44:14 +08:00
|
|
|
|
internal override void Decode(Dictionary<string, object> msgData) {
|
|
|
|
|
if (msgData.TryGetValue(MessageTextKey, out object value)) {
|
2020-03-18 16:21:29 +08:00
|
|
|
|
Text = value as string;
|
|
|
|
|
}
|
2020-03-12 16:23:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|