* LCIMConversation.cs:
* LCIMConversationQuery.cs: * RealtimeConsole.csproj: chore: 支持对话的查询和反序列化
parent
92ee97d236
commit
5dcdc56f56
|
@ -14,6 +14,10 @@ namespace LeanCloud.Realtime {
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string UniqueId {
|
||||||
|
get; internal set;
|
||||||
|
}
|
||||||
|
|
||||||
public string Name {
|
public string Name {
|
||||||
get {
|
get {
|
||||||
return this["name"] as string;
|
return this["name"] as string;
|
||||||
|
@ -30,6 +34,10 @@ namespace LeanCloud.Realtime {
|
||||||
get; internal set;
|
get; internal set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<string> MutedMemberIdList {
|
||||||
|
get; internal set;
|
||||||
|
}
|
||||||
|
|
||||||
public DateTime CreatedAt {
|
public DateTime CreatedAt {
|
||||||
get; internal set;
|
get; internal set;
|
||||||
}
|
}
|
||||||
|
@ -506,11 +514,24 @@ namespace LeanCloud.Realtime {
|
||||||
if (conv.TryGetValue("objectId", out object idObj)) {
|
if (conv.TryGetValue("objectId", out object idObj)) {
|
||||||
Id = idObj as string;
|
Id = idObj as string;
|
||||||
}
|
}
|
||||||
|
if (conv.TryGetValue("uniqueId", out object uniqueIdObj)) {
|
||||||
if (conv.TryGetValue("unique", out object uniqueObj)) {
|
UniqueId = uniqueIdObj as string;
|
||||||
|
}
|
||||||
|
if (conv.TryGetValue("createdAt", out object createdAtObj)) {
|
||||||
|
CreatedAt = DateTime.Parse(createdAtObj.ToString());
|
||||||
|
}
|
||||||
|
if (conv.TryGetValue("updatedAt", out object updatedAtObj)) {
|
||||||
|
UpdatedAt = DateTime.Parse(updatedAtObj.ToString());
|
||||||
|
}
|
||||||
|
if (conv.TryGetValue("c", out object co)) {
|
||||||
|
CreatorId = co as string;
|
||||||
|
}
|
||||||
|
if (conv.TryGetValue("m", out object mo)) {
|
||||||
|
MemberIdList = mo as List<string>;
|
||||||
|
}
|
||||||
|
if (conv.TryGetValue("mu", out object muo)) {
|
||||||
|
MutedMemberIdList = muo as List<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
using System;
|
using System.Threading.Tasks;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using LeanCloud.Storage.Internal.Query;
|
using LeanCloud.Storage.Internal.Query;
|
||||||
using LeanCloud.Realtime.Protocol;
|
using LeanCloud.Realtime.Protocol;
|
||||||
|
using LeanCloud.Storage.Internal;
|
||||||
|
using LeanCloud.Storage.Internal.Codec;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace LeanCloud.Realtime {
|
namespace LeanCloud.Realtime {
|
||||||
public class LCIMConversationQuery {
|
public class LCIMConversationQuery {
|
||||||
|
@ -242,14 +244,22 @@ namespace LeanCloud.Realtime {
|
||||||
ConvCommand conv = new ConvCommand();
|
ConvCommand conv = new ConvCommand();
|
||||||
string where = condition.BuildWhere();
|
string where = condition.BuildWhere();
|
||||||
if (!string.IsNullOrEmpty(where)) {
|
if (!string.IsNullOrEmpty(where)) {
|
||||||
conv.Where = JsonObjectMessage.Parser.ParseJson(where);
|
conv.Where = new JsonObjectMessage {
|
||||||
|
Data = where
|
||||||
|
};
|
||||||
}
|
}
|
||||||
command.ConvMessage = conv;
|
command.ConvMessage = conv;
|
||||||
GenericCommand response = await client.connection.SendRequest(command);
|
GenericCommand response = await client.connection.SendRequest(command);
|
||||||
JsonObjectMessage results = response.ConvMessage.Results;
|
JsonObjectMessage results = response.ConvMessage.Results;
|
||||||
List<LCIMConversation> convList = null;
|
List<object> convs = JsonConvert.DeserializeObject<List<object>>(results.Data, new LCJsonConverter());
|
||||||
// TODO 反序列化
|
List<LCIMConversation> convList = new List<LCIMConversation>(convs.Count);
|
||||||
|
foreach (object c in convs) {
|
||||||
|
Dictionary<string, object> cd = c as Dictionary<string, object>;
|
||||||
|
string convId = cd["objectId"] as string;
|
||||||
|
LCIMConversation conversation = client.GetOrCreateConversation(convId);
|
||||||
|
conversation.MergeFrom(cd);
|
||||||
|
convList.Add(conversation);
|
||||||
|
}
|
||||||
return convList;
|
return convList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<RootNamespace>RealtimeConsole</RootNamespace>
|
<RootNamespace>RealtimeConsole</RootNamespace>
|
||||||
<AssemblyName>RealtimeConsole</AssemblyName>
|
<AssemblyName>RealtimeConsole</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<ReleaseVersion>0.1.0</ReleaseVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
@ -49,6 +50,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="LocalSignatureFactory.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Common\Common.csproj">
|
<ProjectReference Include="..\..\Common\Common.csproj">
|
||||||
|
|
Loading…
Reference in New Issue