Example #1
0
        /// <summary>
        /// 根据成员ID集合查询对应的成员信息
        /// </summary>
        /// <param name="roomId">聊天室ID</param>
        /// <param name="idCollection">聊天室成员ID集合</param>
        /// <param name="cb">查询结果委托</param>
        public static void QueryMemberInfosByIdCollection(long roomId, string[] idCollection, QueryMembersResultDelegate cb)
        {
            var ptr    = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
            var idJson = NimUtility.Json.JsonParser.Serialize(idCollection);

            ChatRoomNativeMethods.nim_chatroom_get_members_by_ids_online_async(roomId, idJson, null, CallbackBridge.QueryMembersCallback, ptr);
        }
Example #2
0
        /// <summary>
        /// 更新我的信息;
        /// </summary>
        /// <param name="roomId">聊天室ID</param>
        /// <param name="info">只支持修改nick,avatar,ext字段修改</param>
        /// <param name="cb">操作结果回调</param>
        /// <param name="notify">是否聊天室内广播通知</param>
        /// <param name="notify_ext">通知中的自定义字段,长度限制2048</param>
        public static void UpdateMyRoleInfo(long roomId, MemberInfo info, UpdateMyRoleDelegate cb, bool notify, string notify_ext, string jsonExt = null)
        {
            var ptr  = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
            var json = info.Serialize();

            ChatRoomNativeMethods.nim_chatroom_update_my_role_async(roomId, json, notify, notify_ext, jsonExt, CallbackBridge.UpdateMyRoleCallback, ptr);
        }
Example #3
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);
        }
Example #4
0
        /// <summary>
        /// (聊天室管理员权限)删除麦序队列
        /// </summary>
        /// <param name="roomId"></param>
        /// <param name="cb"></param>
        /// <param name="json_extension"></param>
        public static void QueueDropAsync(long roomId, ChatRoomQueueDropDelegate cb, string json_extension = "")
        {
            //ChatRoomQueueDropDelegate
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            ChatRoomNativeMethods.nim_chatroom_queue_drop_async(roomId, json_extension, CallbackBridge.ChatroomQueueDropCallback, ptr);
        }
Example #5
0
        /// <summary>
        /// 初始化聊天实模块
        /// </summary>
        public static void Init(NIMChatRoomConfig config = null)
        {
            if (_chatRoomInitialized)
            {
                return;
            }
            try
            {
                string json = config != null?config.Serialize() : "";

                ChatRoomNativeMethods.nim_chatroom_init(json);
                RegisterLoginCallback();
                RegisterExitChatRoomCallback();
                RegisterLinkStateChangedCallback();
                RegisterReceiveMsgCallback();
                RegisterReceiveNotificationMsgCallback();
                RegisterSendMsgArcCallback();
            }
            catch (Exception e)
            {
                _chatRoomInitialized = false;
                System.Diagnostics.Debug.WriteLine(e.ToString());
            }
            _chatRoomInitialized = true;
        }
Example #6
0
        /// <summary>
        /// 取出麦序头元素
        /// </summary>
        /// <param name="roomId">聊天室ID</param>
        /// <param name="element_key">需要取出的元素的UniqKey,长度限制128字节,传空传表示取出第一个元素</param>
        /// <param name="cb"></param>
        /// <param name="json_extension"></param>
        public static void QueuePollAsync(long roomId, string element_key, ChatRoomQueuePollDelegate cb, string json_extension = "")
        {
            //ChatRoomQueuePollDelegate
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            ChatRoomNativeMethods.nim_chatroom_queue_poll_async(roomId, element_key, json_extension, CallbackBridge.ChatroomQueuePollCallback, ptr);
        }
Example #7
0
        /// <summary>
        /// (聊天室管理员权限)新加(更新)麦序队列元素,如果element_key对应的元素已经在队列中存在了,那就是更新操作,如果不存在,就放到队列尾部
        /// </summary>
        /// <param name="roomId">聊天室ID</param>
        /// <param name="element_key">新元素的UniqKey,长度限制128字节 </param>
        /// <param name="elemnet_value">新元素内容,长度限制4096字节 </param>
        /// <param name="cb"></param>
        /// <param name="json_extension"></param>
        public static void QueueOfferAsync(long roomId, string element_key, string elemnet_value, ChatRoomQueueOfferDelegate cb, string json_extension = "")
        {
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            ChatRoomNativeMethods.nim_chatroom_queue_offer_async(roomId, element_key, elemnet_value, json_extension, CallbackBridge.ChatroomQueueOfferCallback, ptr);
            //ChatRoomNativeMethods.nim_chatroom_queue_offer_async(roomId, element_key, elemnet_value, json_extension, cb, IntPtr.Zero);
        }
 /// <summary>
 /// 排序列出所有麦序元素
 /// </summary>
 /// <param name="roomId">房间号</param>
 /// <param name="cb"></param>
 /// <param name="json_extension"></param>
 public static void QueueListAsync(long roomId, nim_chatroom_queue_list_cb_func cb, string json_extension = "")
 {
     //ChatRoomQueueListDelegate
     //          var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
     //          ChatRoomNativeMethods.nim_chatroom_queue_list_async(roomId, json_extension, CallbackBridge.ChatroomQueueListCallback,ptr);
     ChatRoomNativeMethods.nim_chatroom_queue_list_async(roomId, json_extension, cb, IntPtr.Zero);
 }
Example #9
0
 /// <summary>
 /// 清理聊天室模块
 /// </summary>
 public static void Cleanup()
 {
     if (_chatRoomInitialized)
     {
         ChatRoomNativeMethods.nim_chatroom_cleanup(null);
         _chatRoomInitialized = false;
     }
 }
Example #10
0
        /// <summary>
        /// 登陆聊天室
        /// </summary>
        /// <param name="roomId">聊天室ID</param>
        /// <param name="request">聊天室登录信息(NIM SDK请求聊天室返回的数据)</param>
        /// <param name="loginData">聊天室可选信息</param>
        public static void Login(long roomId, string request, LoginData loginData = null)
        {
            string loginJson = string.Empty;

            if (loginData != null)
            {
                loginJson = loginData.Serialize();
            }
            ChatRoomNativeMethods.nim_chatroom_enter(roomId, request, loginJson, string.Empty);
        }
Example #11
0
        /// <summary>
        /// 获取匿名登录聊天室地址(仅供demo测试使用,用户需要自己的应用服务器来获取聊天室地址)
        /// </summary>
        /// <param name="roomId"></param>
        /// <param name="appKey"></param>
        /// <param name="callback"></param>
        public static void RequestLinkInfoWithAnonymous(long roomId, string appKey, RequestChatRoomLinkInfoDelegate callback)
        {
            if (string.IsNullOrEmpty(appKey))
            {
                return;
            }
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(callback);

            ChatRoomNativeMethods.nim_chatroom_request_link_service_with_anonymous(roomId, appKey, null, CallbackBridge.RequestChatRoomLinkInfoCallback, ptr);
        }
Example #12
0
 /// <summary>
 /// 初始化聊天实模块
 /// </summary>
 public static void Init()
 {
     ChatRoomNativeMethods.nim_chatroom_init(null);
     RegisterLoginCallback();
     RegisterExitChatRoomCallback();
     RegisterLinkStateChangedCallback();
     RegisterReceiveMsgCallback();
     RegisterReceiveNotificationMsgCallback();
     RegisterSendMsgArcCallback();
 }
Example #13
0
        /// <summary>
        /// 在线查询消息历史记录
        /// </summary>
        /// <param name="roomId">聊天室ID</param>
        /// <param name="startTimeStamp">起始时间戳</param>
        /// <param name="count">查询数量</param>
        /// <param name="cb">查询结果委托</param>
        public static void QueryMessageHistoryOnline(long roomId, long startTimeStamp, int count, QueryMessageHistoryResultDelegate cb)
        {
            QueryMessageHistoryParam param = new QueryMessageHistoryParam();

            param.Count     = count;
            param.StartTime = startTimeStamp;
            string queryJsonParam = param.Serialize();
            var    ptr            = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            ChatRoomNativeMethods.nim_chatroom_get_msg_history_online_async(roomId, queryJsonParam, null, CallbackBridge.QueryMessageLogCallback, ptr);
        }
Example #14
0
        /// <summary>
        /// 设置成员身份标识
        /// </summary>
        /// <param name="roomId">聊天室ID</param>
        /// <param name="property">成员属性</param>
        /// <param name="cb">操作结果委托</param>
        public static void SetMemberPropertyOnline(long roomId, MemberProperty property, SetMemberPropertyDelegate cb)
        {
            if (property == null || string.IsNullOrEmpty(property.MemberId))
            {
                throw new ArgumentException("MemberId can't be null or empty");
            }
            var jsonParam = property.Serialize();
            var ptr       = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            ChatRoomNativeMethods.nim_chatroom_set_member_attribute_async(roomId, jsonParam, null, CallbackBridge.SetMemberPropertyCallback, ptr);
        }
Example #15
0
        /// <summary>
        /// 在线查询聊天室成员
        /// </summary>
        /// <param name="roomId">聊天室ID</param>
        /// <param name="memberType">成员类型</param>
        /// <param name="timeOffset">距离当前时间的时间戳</param>
        /// <param name="limit">查询数量</param>
        /// <param name="cb">查询结果委托</param>
        public static void QueryMembersOnline(long roomId, NIMChatRoomGetMemberType memberType, long timeOffset, int limit, QueryMembersResultDelegate cb)
        {
            QueryChatRoomMembersParam param = new QueryChatRoomMembersParam();

            param.MemberType = memberType;
            param.Count      = limit;
            param.TimeOffset = timeOffset;
            string queryJsonParam = param.Serialize();
            var    ptr            = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            ChatRoomNativeMethods.nim_chatroom_get_members_online_async(roomId, queryJsonParam, null, CallbackBridge.QueryMembersCallback, ptr);
        }
Example #16
0
        public static void LoginWithAnonymous(long roomId, AnonymousInfo anonymityInfo, LoginData loginData = null)
        {
            string loginJson = string.Empty;

            if (loginData != null)
            {
                loginJson = loginData.Serialize();
            }

            if (anonymityInfo == null)
            {
                return;
            }

            string anonymity_info = anonymityInfo.Serialize();

            ChatRoomNativeMethods.nim_chatroom_enter_with_anoymity(roomId, anonymity_info, loginJson, null);
        }
Example #17
0
 /// <summary>
 /// 初始化聊天实模块
 /// </summary>
 public static void Init()
 {
     if (_chatRoomInitialized)
     {
         return;
     }
     try
     {
         ChatRoomNativeMethods.nim_chatroom_init("");
         RegisterLoginCallback();
         RegisterExitChatRoomCallback();
         RegisterLinkStateChangedCallback();
         RegisterReceiveMsgCallback();
         RegisterReceiveNotificationMsgCallback();
         RegisterSendMsgArcCallback();
     }
     catch (Exception e)
     {
         _chatRoomInitialized = false;
         System.Diagnostics.Debug.WriteLine(e.ToString());
     }
     _chatRoomInitialized = true;
 }
Example #18
0
 /// <summary>
 /// 初始化聊天实模块
 /// </summary>
 public static void Init()
 {
     if (_chatRoomInitialized)
     {
         return;
     }
     try
     {
         ChatRoomNativeMethods.nim_chatroom_init(null);
         RegisterLoginCallback();
         RegisterExitChatRoomCallback();
         RegisterLinkStateChangedCallback();
         RegisterReceiveMsgCallback();
         RegisterReceiveNotificationMsgCallback();
         RegisterSendMsgArcCallback();
     }
     catch (Exception e)
     {
         _chatRoomInitialized = false;
         NimUtility.Log.Error(e.Message);
     }
     _chatRoomInitialized = true;
 }
Example #19
0
        /// <summary>
        /// 查看麦序头元素
        /// </summary>
        /// <param name="roomID">聊天室ID</param>
        /// <param name="cb">回调函数</param>
        /// <param name="json"></param>
        public static void QueueHeaderAsync(long roomID, ChatRoomQueueHeaderDelegate cb, string json = null)
        {
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            ChatRoomNativeMethods.nim_chatroom_queue_header_async(roomID, json, CallbackBridge.ChatroomQueueHeaderCallback, ptr);
        }
Example #20
0
 private static void RegisterExitChatRoomCallback()
 {
     ChatRoomNativeMethods.nim_chatroom_reg_exit_cb(null, ParseExitChatRoomResult, IntPtr.Zero);
 }
Example #21
0
 private static void RegisterLoginCallback()
 {
     ChatRoomNativeMethods.nim_chatroom_reg_enter_cb(null, ParaseChatRoomLoginResult, IntPtr.Zero);
 }
Example #22
0
 /// <summary>
 /// 发送消息
 /// </summary>
 /// <param name="roomId">房间ID</param>
 /// <param name="msg">消息内容</param>
 public static void SendMessage(long roomId, Message msg)
 {
     msg.ClientMsgId = NimUtility.Utilities.GenerateGuid();
     ChatRoomNativeMethods.nim_chatroom_send_msg(roomId, msg.Serialize(), null);
 }
Example #23
0
        /// <summary>
        /// 临时禁言/解禁成员
        /// </summary>
        /// <param name="roomId">聊天室ID</param>
        /// <param name="accid">成员ID</param>
        /// <param name="duration">临时禁言时长(秒),解禁填0</param>
        /// <param name="cb">操作结果回调</param>
        /// <param name="notify">是否聊天室内广播通知</param>
        /// <param name="notify_ext">通知中的自定义字段,长度限制2048</param>
        public static void TempMuteMember(long roomId, string accid, long duration, TempMuteMemberDelegate cb, bool notify, string notify_ext)
        {
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            ChatRoomNativeMethods.nim_chatroom_temp_mute_member_async(roomId, accid, duration, notify, notify_ext, null, CallbackBridge.TempMuteMemberCallback, ptr);
        }
Example #24
0
 private static void RegisterSendMsgArcCallback()
 {
     ChatRoomNativeMethods.nim_chatroom_reg_send_msg_ack_cb(null, SendMsgAckCallback, IntPtr.Zero);
 }
Example #25
0
        /// <summary>
        /// 将指定成员移出聊天室
        /// </summary>
        /// <param name="roomId">聊天室ID</param>
        /// <param name="memberId">成员ID</param>
        /// <param name="notify">放到事件通知中的扩展字段</param>
        /// <param name="cb">操作结果委托</param>
        public static void RemoveMember(long roomId, string memberId, string notify, RemoveMemberDelegate cb)
        {
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            ChatRoomNativeMethods.nim_chatroom_kick_member_async(roomId, memberId, notify, null, CallbackBridge.KickoutMemberCallback, ptr);
        }
Example #26
0
 /// <summary>
 /// 获取聊天室状态;
 /// </summary>
 /// <param name="roomId">聊天室ID</param>
 /// <returns></returns>
 public static int GetLoginState(long roomId)
 {
     return(ChatRoomNativeMethods.nim_chatroom_get_login_state(roomId, null));
 }
Example #27
0
        /// <summary>
        /// 获取聊天室信息
        /// </summary>
        /// <param name="roomId">聊天室ID</param>
        /// <param name="cb">查询结果委托</param>
        public static void GetRoomInfo(long roomId, GetRoomInfoDelegate cb)
        {
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            ChatRoomNativeMethods.nim_chatroom_get_info_async(roomId, null, CallbackBridge.GetRoomInfoCallback, ptr);
        }
Example #28
0
 private static void RegisterReceiveMsgCallback()
 {
     ChatRoomNativeMethods.nim_chatroom_reg_receive_msg_cb(null, ReceiveMessageCallback, IntPtr.Zero);
 }
Example #29
0
 private static void RegisterReceiveNotificationMsgCallback()
 {
     ChatRoomNativeMethods.nim_chatroom_reg_receive_notification_cb(null, OnReceiveChatRoomNotificationMsg, IntPtr.Zero);
 }
Example #30
0
 private static void RegisterLinkStateChangedCallback()
 {
     ChatRoomNativeMethods.nim_chatroom_reg_link_condition_cb(null, LinkStateChangedCallback, IntPtr.Zero);
 }