unity c# 设置获取已读 未读消息

用的是最新版sdk 好得 谢谢了

您好 我看了 新的sdk 没有加入一个对话的api 这个功能是去掉了吗 还是跟 获取一个对话 的合在一起了

换了新的 sdk后 提示我 Assets\Zero\Editor\Scripts\EditorWins\GenerateCode\Excel2ProtobufModule.cs(505,84): error CS0433: The type 'CodedOutputStream' exists in both 'Assembly-CSharp, Version=3.11.4.0, Culture=neutral, PublicKeyToken=null' and 'Google.Protobuf, Version=3.11.4.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604'
说 这个类 在俩个dll里面 都包括了 但是我删除一个 就会报其他错误 请问一些唉 有什么可解决方案吗

这个看起来是其他插件(Excel2ProtobufModule)与 LeanCloud SDK 的依赖(Protobuf)冲突。
如果这两个库使用的 protobuf 版本是一致的,理论上删除一个即可。
如果 protobuf 不兼容,则需要考虑适配一下,可以选择重新编译 Excel2ProtobufModule 或者 LeanCloud SDK。如果重新编译 LeanCloud SDK,则无法保证兼容性和稳定性。

那个是网络框架的 刚刚看了下 那边也不能删除的 这个也不能删除 很苦恼!!!!

用的SDK版本 realtime-SDK-dotNET-v20200121.1.tar 4.6

大佬 天在下雨 俺在等你回复

如果是旧的 SDK,尝试在 AVIMClient 创建完成后,将 AVIMClient.CurrentConfiguration.AutoRead 设置为 false

请打印下接收消息后的日志,主要看下有没有「已读消息」发出

请选中发送「已读消息」请求的日志,看一下调用堆栈

websocket=>{"convs":[{"cid":"5f9bd86281cfda70d6825f14","mid":"s7fjlkcPRfqyhRIoX3Nxxg","timestamp":1605235756580}],"i":-65518,"cmd":"read","appId":"PVN1HKESHfBwMqAepgcYyYcG-gzGzoHsz","peerId":"13552994"}
UnityEngine.Debug:Log(Object)
LeanCloud.Realtime.AVRealtime:PrintLog(String)
LeanCloud.Realtime.Internal.AVIMCommandRunner:RunCommandAsync(AVIMCommand, CancellationToken)
LeanCloud.Realtime.AVRealtime:RunCommandAsync(AVIMCommand)
LeanCloud.Realtime.AVIMClient:RunCommandAsync(AVIMCommand)
LeanCloud.Realtime.AVIMClient:ReadAsync(AVIMConversation, IAVIMMessage, Nullable1)
LeanCloud.Realtime.AVIMConversation:ReadAsync(IAVIMMessage, Nullable
1)
LeanCloud.Realtime.AVIMConversation:CurrentClient_OnMessageReceived(Object, AVIMMessageEventArgs)
LeanCloud.Realtime.AVIMClient:MessageListener_OnMessageReceived(Object, AVIMMessageEventArgs)
LeanCloud.Realtime.AVIMMessageListener:OnMessage(AVIMNotice)
LeanCloud.Realtime.AVIMMessageListener:OnNoticeReceived(AVIMNotice)
LeanCloud.Realtime.<>c__DisplayClass82_0:b__0(Object, AVIMNotice)
LeanCloud.Realtime.AVRealtime:WebSocketClient_OnMessage(String)
LeanCloud.Realtime.Internal.DefaultWebSocketClient:OnWebSokectMessage(Object, MessageEventArgs)
WebSocketSharp.Ext:Emit(EventHandler1, Object, MessageEventArgs)
WebSocketSharp.WebSocket:messagec(MessageEventArgs)
WebSocketSharp.WebSocket:message()
WebSocketSharp.<>c__DisplayClass174_0:<startReceiving>b__1(WebSocketFrame)
WebSocketSharp.<>c__DisplayClass83_0:<ReadFrameAsync>b__3(WebSocketFrame)
WebSocketSharp.<>c__DisplayClass77_0:<readPayloadDataAsync>b__0(Byte[])
WebSocketSharp.<>c__DisplayClass56_0:<ReadBytesAsync>b__0(IAsyncResult)
System.Threading.Tasks.TaskToApm:Begin(Task, AsyncCallback, Object)
Mono.Net.Security.MobileAuthenticatedStream:BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)
System.Net.Security.SslStream:BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)
WebSocketSharp.Ext:ReadBytesAsync(Stream, Int32, Action
1, Action1)
WebSocketSharp.WebSocketFrame:readPayloadDataAsync(Stream, WebSocketFrame, Action
1, Action1)
WebSocketSharp.<>c__DisplayClass83_0:<ReadFrameAsync>b__2(WebSocketFrame)
WebSocketSharp.WebSocketFrame:readMaskingKeyAsync(Stream, WebSocketFrame, Action
1, Action1)
WebSocketSharp.<>c__DisplayClass83_0:<ReadFrameAsync>b__1(WebSocketFrame)
WebSocketSharp.<>c__DisplayClass71_0:<readExtendedPayloadLengthAsync>b__0(Byte[])
WebSocketSharp.<>c__DisplayClass56_0:<ReadBytesAsync>b__0(IAsyncResult)
System.Threading.Tasks.TaskToApm:Begin(Task, AsyncCallback, Object)
Mono.Net.Security.MobileAuthenticatedStream:BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)
System.Net.Security.SslStream:BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)
WebSocketSharp.Ext:ReadBytesAsync(Stream, Int32, Action
1, Action1)
WebSocketSharp.WebSocketFrame:readExtendedPayloadLengthAsync(Stream, WebSocketFrame, Action
1, Action1)
WebSocketSharp.<>c__DisplayClass83_0:<ReadFrameAsync>b__0(WebSocketFrame)
WebSocketSharp.<>c__DisplayClass73_0:<readHeaderAsync>b__0(Byte[])
WebSocketSharp.<>c__DisplayClass56_0:<ReadBytesAsync>b__0(IAsyncResult)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder
1:SetResult(Int32)
Mono.Net.Security.d__58:MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetResult(AsyncProtocolResult)
Mono.Net.Security.<StartOperation>d__23:MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:SetResult()
Mono.Net.Security.<ProcessOperation>d__24:MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder
1:SetResult(Nullable1)
Mono.Net.Security.<InnerRead>d__25:MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder
1:SetResult(Int32)
Mono.Net.Security.d__66:MoveNext()
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback()
这是第一条的全部日志 看看我哪里设置错了么

这里 判断了 AutoRead = true 时会自动发送「已读消息通知」。
请在实例化 AVIMClient 之后,将 AVIMClient.CurrentConfiguration.AutoRead 设置为 false

AVClient.Initialize (ChatData.Ins.appId , ChatData.Ins.appKey , ChatData.Ins.server);
var realtimeConfig = new AVRealtime.Configuration ()
{
ApplicationId = ChatData.Ins.appId ,
ApplicationKey = ChatData.Ins.appKey ,
OfflineMessageStrategy = AVRealtime.OfflineMessageStrategy.UnreadAck ,
};
ChatData.Ins.realtime = new AVRealtime (realtimeConfig);
//CharData.Ins.realtime = new AVRealtime (CharData.Ins.appId, CharData.Ins.appKey);
ChatData.Ins.tom = await ChatData.Ins.realtime.CreateClientAsync (ItemData.Ins.playerInfo.Uid.ToString ());
var auto = ChatData.Ins.tom.CurrentConfiguration;
auto.AutoRead = false;
已经设置过了 不管用啊

Configuration 是 struct,请改成

ChatData.Ins.tom.CurrentConfiguration.AutoRead = false;

client.CurrentConfiguration = new LeanCloud.Realtime.AVIMClient.Configuration {
    AutoRead = false
};

websocket=>{"mid":"pMmdYP5uTJ2xfXSnJxMeOg","cid":"5fae283b0d3a42c5fd705860","i":-65525,"cmd":"ack","appId":"PVN1HKESHfBwMqAepgcYyYcG-gzGzoHsz","peerId":"13552995"}
UnityEngine.Debug:Log(Object)
LeanCloud.Realtime.AVRealtime:PrintLog(String)
LeanCloud.Realtime.Internal.AVIMCommandRunner:RunCommandAsync(AVIMCommand, CancellationToken)
LeanCloud.Realtime.AVRealtime:RunCommandAsync(AVIMCommand)
LeanCloud.Realtime.AVIMClient:RunCommandAsync(AVIMCommand)
LeanCloud.Realtime.AVIMClient:AckListener_OnMessageReceieved(Object, AVIMMessageEventArgs)
LeanCloud.Realtime.AVIMClient:MessageListener_OnMessageReceived(Object, AVIMMessageEventArgs)
LeanCloud.Realtime.AVIMMessageListener:OnMessage(AVIMNotice)
LeanCloud.Realtime.AVIMMessageListener:OnNoticeReceived(AVIMNotice)
LeanCloud.Realtime.<>c__DisplayClass82_0:b__0(Object, AVIMNotice)
LeanCloud.Realtime.AVRealtime:WebSocketClient_OnMessage(String)
LeanCloud.Realtime.Internal.DefaultWebSocketClient:OnWebSokectMessage(Object, MessageEventArgs)
WebSocketSharp.Ext:Emit(EventHandler1, Object, MessageEventArgs)
WebSocketSharp.WebSocket:messagec(MessageEventArgs)
WebSocketSharp.WebSocket:message()
WebSocketSharp.<>c__DisplayClass174_0:<startReceiving>b__1(WebSocketFrame)
WebSocketSharp.<>c__DisplayClass83_0:<ReadFrameAsync>b__3(WebSocketFrame)
WebSocketSharp.<>c__DisplayClass77_0:<readPayloadDataAsync>b__0(Byte[])
WebSocketSharp.<>c__DisplayClass56_0:<ReadBytesAsync>b__0(IAsyncResult)
System.Threading.Tasks.TaskToApm:Begin(Task, AsyncCallback, Object)
Mono.Net.Security.MobileAuthenticatedStream:BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)
System.Net.Security.SslStream:BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)
WebSocketSharp.Ext:ReadBytesAsync(Stream, Int32, Action
1, Action1)
WebSocketSharp.WebSocketFrame:readPayloadDataAsync(Stream, WebSocketFrame, Action
1, Action1)
WebSocketSharp.<>c__DisplayClass83_0:<ReadFrameAsync>b__2(WebSocketFrame)
WebSocketSharp.WebSocketFrame:readMaskingKeyAsync(Stream, WebSocketFrame, Action
1, Action1)
WebSocketSharp.<>c__DisplayClass83_0:<ReadFrameAsync>b__1(WebSocketFrame)
WebSocketSharp.<>c__DisplayClass71_0:<readExtendedPayloadLengthAsync>b__0(Byte[])
WebSocketSharp.<>c__DisplayClass56_0:<ReadBytesAsync>b__0(IAsyncResult)
System.Threading.Tasks.TaskToApm:Begin(Task, AsyncCallback, Object)
Mono.Net.Security.MobileAuthenticatedStream:BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)
System.Net.Security.SslStream:BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)
WebSocketSharp.Ext:ReadBytesAsync(Stream, Int32, Action
1, Action1)
WebSocketSharp.WebSocketFrame:readExtendedPayloadLengthAsync(Stream, WebSocketFrame, Action
1, Action1)
WebSocketSharp.<>c__DisplayClass83_0:<ReadFrameAsync>b__0(WebSocketFrame)
WebSocketSharp.<>c__DisplayClass73_0:<readHeaderAsync>b__0(Byte[])
WebSocketSharp.<>c__DisplayClass56_0:<ReadBytesAsync>b__0(IAsyncResult)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder
1:SetResult(Int32)
Mono.Net.Security.d__58:MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetResult(AsyncProtocolResult)
Mono.Net.Security.<StartOperation>d__23:MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:SetResult()
Mono.Net.Security.<ProcessOperation>d__24:MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder
1:SetResult(Nullable1)
Mono.Net.Security.<InnerRead>d__25:MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder
1:SetResult(Int32)
Mono.Net.Security.d__66:MoveNext()
System.Threading._ThreadPoolWaitCallback:PerformWaitCallback()
还有一个返回 其他三个木有了

改了一下 然后 好像 可以了 感谢大佬了 非常感谢

参考这里

AVRealtime.CurrentConfiguration.OfflineMessageStrategy = OfflineMessageStrategy.UnreadAck

尽快使用新版 SDK 吧

网络框架和新版 SDK冲突 占时改不了啊 新版的日志 打印 看着有点乱 还有 这个旧版 收到消息的时候 会给 本地已获取\创建 的所有消息都加一 未读 有没有其他人遇到过这种情况啊