Merge pull request #69 from onerain88/fix_rtm

Fix rtm
oneRain 2020-05-20 14:36:51 +08:00 committed by GitHub
commit 31865b82bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 7 deletions

View File

@ -477,6 +477,9 @@ namespace LeanCloud.Realtime {
if (conv.TryGetValue("objectId", out object idObj)) {
Id = idObj as string;
}
if (conv.TryGetValue("name", out object nameObj)) {
Name = nameObj as string;
}
if (conv.TryGetValue("unique", out object uniqueObj)) {
Unique = (bool)uniqueObj;
}

View File

@ -43,18 +43,21 @@ namespace LeanCloud.Realtime.Internal.Controller {
if (members != null) {
conv.M.AddRange(members);
}
if (!string.IsNullOrEmpty(name)) {
conv.N = name;
}
if (temporary) {
conv.TempConv = temporary;
conv.TempConvTTL = temporaryTtl;
}
if (properties != null) {
conv.Attr = new JsonObjectMessage {
Data = JsonConvert.SerializeObject(LCEncoder.Encode(properties))
};
Dictionary<string, object> attrs = new Dictionary<string, object>();
if (!string.IsNullOrEmpty(name)) {
attrs["name"] = name;
}
if (properties != null) {
attrs = properties.Union(attrs)
.ToDictionary(k => k.Key, v => v.Value);
}
conv.Attr = new JsonObjectMessage {
Data = JsonConvert.SerializeObject(LCEncoder.Encode(attrs))
};
if (Client.SignatureFactory != null) {
LCIMSignature signature = await Client.SignatureFactory.CreateStartConversationSignature(Client.Id, members);
conv.S = signature.Signature;
@ -84,6 +87,8 @@ namespace LeanCloud.Realtime.Internal.Controller {
conversation.CreatorId = Client.Id;
conversation.ids = members != null ?
new HashSet<string>(members) : new HashSet<string>();
// 将自己加入
conversation.ids.Add(Client.Id);
conversation.CreatedAt = DateTime.Parse(response.ConvMessage.Cdate);
conversation.UpdatedAt = conversation.CreatedAt;
return conversation;

View File

@ -70,6 +70,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
AckCommand ack = response.AckMessage;
message.Id = ack.Uid;
message.SentTimestamp = ack.T;
message.FromClientId = Client.Id;
return message;
}