Exemplo n.º 1
0
        /// <summary>
        /// 更新聊天室信息;
        /// </summary>
        /// <param name="roomId">聊天室ID</param>
        /// <param name="info">只支持修改name,announcement,broadcast_url,ext字段修改</param>
        /// <param name="cb">操作结果回调</param>
        /// <param name="notify">是否聊天室内广播通知</param>
        /// <param name="notify_ext">通知中的自定义字段,长度限制2048</param>
        public static void UpdateRoomInfo(long roomId, ChatRoomInfo info, UpdateRoomInfoDelegate cb, bool notify, string notify_ext)
        {
            var ptr  = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
            var json = info.Serialize();

            ChatRoomNativeMethods.nim_chatroom_update_room_info_async(roomId, json, notify, notify_ext, null, CallbackBridge.UpdateRoomInfoCallback, ptr);
        }
Exemplo n.º 2
0
        List <ChatRoomInfo> ParseResponseJson(string jsonContent)
        {
            JObject jObj      = JObject.Parse(jsonContent);
            var     resToken  = jObj.SelectToken("res");
            var     listToken = jObj.SelectToken("msg.list");

            if (resToken == null || resToken.ToObject <int>() != 200 || listToken == null)
            {
                return(null);
            }

            var rooms = listToken.ToArray();
            List <ChatRoomInfo> roomList = new List <ChatRoomInfo>();

            foreach (var r in rooms)
            {
                var room = new ChatRoomInfo();
                room.RoomId             = r.Value <int>("roomid");
                room.RoomName           = r.Value <string>("name");
                room.CreatorId          = r.Value <string>("creator");
                room.OnlineMembersCount = r.Value <int>("onlineusercount");
                room.Valid        = r.Value <int>("status");
                room.Extension    = r.Value <string>("ext");
                room.Announcement = r.Value <string>("announcement");
                room.BroadcastUrl = r.Value <string>("broadcasturl");
                roomList.Add(room);
            }
            return(roomList);
        }
Exemplo n.º 3
0
        private static void OnGetRoomInfo(long roomId, int errorCode, string result, string jsonExtension, IntPtr userData)
        {
            ChatRoomInfo roomInfo = null;
            var          code     = (NIM.ResponseCode)errorCode;

            if (code == NIM.ResponseCode.kNIMResSuccess)
            {
                roomInfo = NimUtility.Json.JsonParser.Deserialize <ChatRoomInfo>(result);
            }
            NimUtility.DelegateConverter.InvokeOnce <GetRoomInfoDelegate>(userData, roomId, code, roomInfo);
        }
Exemplo n.º 4
0
 void ChatRoomApi_LoginHandler(NIMChatRoom.NIMChatRoomLoginStep loginStep, NIM.ResponseCode errorCode, NIMChatRoom.ChatRoomInfo roomInfo, NIMChatRoom.MemberInfo memberInfo)
 {
     Debug.Log("ChatRoomApi_LoginHandler called");
 }
 private void ChatRoomApi_LoginHandler(NIMChatRoom.NIMChatRoomLoginStep loginStep, NIM.ResponseCode errorCode, NIMChatRoom.ChatRoomInfo roomInfo, NIMChatRoom.MemberInfo memberInfo)
 {
     if (loginStep == NIMChatRoom.NIMChatRoomLoginStep.kNIMChatRoomLoginStepRoomAuthOver && errorCode == NIM.ResponseCode.kNIMResSuccess)
     {
         _joinedRoomIdSet.Add(roomInfo.RoomId);
     }
     if (errorCode != NIM.ResponseCode.kNIMResSuccess)
     {
         MessageBox.Show(loginStep.ToString() + " " + errorCode.ToString(), "进入聊天室出错");
     }
 }