LeanCloud 创建聊天室失败

新手上路,请多包涵

问题描述

使用unity2017开发,接入目前最新的leanCloud Sdk ,在使用文档上的推荐方法创建聊天室时失败 m_client.CreateChatRoomAsync(“聊天室”),
错误提示

问题出现的环境背景及自己尝试过哪些方法

使用创建普通对话的方法,设置对话的属性,也就是文档上不推荐的方法。可以成功创建聊天室

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)

调用代码:

AVRealtime avRealtime = new AVRealtime(m_appId, m_appKey);
AVIMClient client = await avRealtime.CreateClientAsync(m_clientId);

await client.CreateChatRoomAsync("我的聊天室");

你期待的结果是什么?实际看到的错误信息又是什么?

期待可以使用文档上的推荐方法,创建成功聊天室,但是有报错
报错log:
System.NullReferenceException: 当前对话没有关联有效的 AVIMClient。
at LeanCloud.Realtime.AVIMConversation.get_CurrentClient () [0x00008] in <d632fe62608d4878ab3ee2352431e2fe>:0
at LeanCloud.Realtime.AVIMConversation..ctor (LeanCloud.Realtime.AVIMClient client) [0x00023] in <d632fe62608d4878ab3ee2352431e2fe>:0
at LeanCloud.Realtime.AVIMConversation..ctor (LeanCloud.Realtime.AVIMConversation source, System.String name, System.String creator, System.Collections.Generic.IEnumerable1[T] members, System.Collections.Generic.IEnumerable1[T] muteMembers, System.Boolean isTransient, System.Boolean isSystem, System.Collections.Generic.IEnumerable`1[T] attributes, LeanCloud.AVObject state, System.Boolean isUnique, System.Boolean isTemporary, System.Int32 ttl, LeanCloud.Realtime.AVIMClient client) [0x00000] in <d632fe62608d4878ab3ee2352431e2fe>:0
at LeanCloud.Realtime.AVIMClient.CreateChatRoomAsync (System.String chatroomName) [0x00000] in <d632fe62608d4878ab3ee2352431e2fe>:0
at GameLeanCloud.ChatClientManager+<SetClient>c__async0.MoveNext () [0x000b4] in /Users/sangshuai/HumanFallFlatSDK/Assets/Scripts/LeanCloud/ChatClientManager.cs:48
UnityEngine.Debug:Log(Object)
GameLeanCloud.<SetClient>c__async0:MoveNext() (at Assets/Scripts/LeanCloud/ChatClientManager.cs:52)
UnityEngine.UnitySynchronizationContext:ExecuteTasks()

阅读 2.7k
2 个回答
新手上路,请多包涵

更新最新版的sdk

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进