using System.Collections.Generic; using LeanCloud.Storage; namespace LeanCloud.Realtime { public class LCIMLocationMessage : LCIMTextMessage { public LCGeoPoint Location { get; set; } internal LCIMLocationMessage() { } public LCIMLocationMessage(LCGeoPoint locaction) : base(null) { Location = locaction; } internal override Dictionary Encode() { Dictionary data = base.Encode(); Dictionary locationData = new Dictionary { { "longitude", Location.Longitude }, { "latitude", Location.Latitude } }; data["_lcloc"] = locationData; return data; } protected override void DecodeMessageData(Dictionary msgData) { base.DecodeMessageData(msgData); Dictionary locationData = msgData["_lcloc"] as Dictionary; Location = new LCGeoPoint((double)locationData["latitude"], (double)locationData["longitude"]); } internal override int MessageType => LocationMessageType; } }