2020-03-18 11:41:13 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using LeanCloud.Storage;
|
|
|
|
|
|
|
|
|
|
namespace LeanCloud.Realtime {
|
|
|
|
|
public class LCIMLocationMessage : LCIMTextMessage {
|
|
|
|
|
public LCGeoPoint Location {
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-18 16:21:29 +08:00
|
|
|
|
internal LCIMLocationMessage() {
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-18 11:41:13 +08:00
|
|
|
|
public LCIMLocationMessage(LCGeoPoint locaction) : base(null) {
|
|
|
|
|
Location = locaction;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-18 16:21:29 +08:00
|
|
|
|
internal override Dictionary<string, object> Encode() {
|
|
|
|
|
Dictionary<string, object> data = base.Encode();
|
|
|
|
|
Dictionary<string, object> locationData = new Dictionary<string, object> {
|
2020-03-18 11:41:13 +08:00
|
|
|
|
{ "longitude", Location.Longitude },
|
|
|
|
|
{ "latitude", Location.Latitude }
|
|
|
|
|
};
|
2020-03-18 16:21:29 +08:00
|
|
|
|
data["_lcloc"] = locationData;
|
|
|
|
|
return data;
|
2020-03-12 16:23:21 +08:00
|
|
|
|
}
|
2020-03-18 16:21:29 +08:00
|
|
|
|
|
|
|
|
|
protected override void DecodeMessageData(Dictionary<string, object> msgData) {
|
|
|
|
|
base.DecodeMessageData(msgData);
|
|
|
|
|
Dictionary<string, object> locationData = msgData["_lcloc"] as Dictionary<string, object>;
|
|
|
|
|
Location = new LCGeoPoint((double)locationData["latitude"], (double)locationData["longitude"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override int MessageType => LocationMessageType;
|
2020-03-12 16:23:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|