/// <summary> /// 方法说明:接收聊天室信息方法 /// 完成时间:2017-05-10 /// </summary> /// <param name="msReceived">接收消息注册</param> /// <param name="msType">聊天室消息类型</param> /// <param name="mqArray">聊天室消息内容</param> /// <param name="errorMsg">错误提示</param> private static void HandleRoomMsReceived(SdkPublicationReceivedHandler msReceived, int msType, string[][] mqArray, ref string errorMsg) { var eventType = SdkMsgType.UnDefineMsg; var roomMsg = MsgConverter.ReceiveRoomMsgEntity(msType, mqArray, ref eventType, ref errorMsg); if (roomMsg == null) { return; } roomMsg.MsgType = eventType; msReceived?.Invoke(eventType, roomMsg); }
/// <summary> /// 方法说明:注册方法接收离线消息 /// </summary> /// <param name="mqofflineArray"></param> /// <returns></returns> private static void HandleOfflineReceived(SdkPublicationReceivedHandler msReceived, IReadOnlyCollection <string> mqofflineArray) { if (mqofflineArray == null || mqofflineArray.Count == 0) { return; } var contentobjList = new List <SdkMsBase>(); foreach (var jsonContent in mqofflineArray) { var mqArray = JsonConvert.DeserializeObject <string[][]>(jsonContent); var errorMsg = string.Empty; var messageType = int.Parse(mqArray[0][0]); var eventType = SdkMsgType.UnDefineMsg; //聊天信息接收:Text、Picture、Audio、File、MapLocation、MixImageText、At、MultiAudioVideo if (Enum.GetValues(typeof(SdkEnumCollection.ChatMsgType)).Cast <int>().ToList().Contains(messageType)) { var chatMsg = MsgConverter.ReceiveChatMsgEntity(messageType, mqArray, ref eventType, ref errorMsg); if (chatMsg == null) { continue; } chatMsg.MsgType = eventType; contentobjList.Add(chatMsg); } //用户信息接收:OffLine、OnLine、Leave、Busy、KickOut、Disable、ModifyInfo if (Enum.GetValues(typeof(SdkEnumCollection.UserStateNotify)).Cast <int>().ToList().Contains(messageType)) { var userMsg = MsgConverter.ReceiveUserMsgEntity(messageType, mqArray, ref eventType, ref errorMsg); if (userMsg == null) { continue; } userMsg.MsgType = eventType; contentobjList.Add(userMsg); } //聊天室信息接收:Create、Dismiss、AddMember、DeleteMember、QuitMember、ModifyMemberInfo、Modify if (Enum.GetValues(typeof(SdkEnumCollection.ChatRoomNotify)).Cast <int>().ToList().Contains(messageType)) { var roomMsg = MsgConverter.ReceiveRoomMsgEntity(messageType, mqArray, ref eventType, ref errorMsg); if (roomMsg == null) { continue; } roomMsg.MsgType = eventType; contentobjList.Add(roomMsg); } //讨论组(群)信息接收:Create、Dismiss、AddMember、DeleteMember、QuitMember、ModifyMemberInfo、Modify、BurnMode、NormalMode、BurnModeDelete if (Enum.GetValues(typeof(SdkEnumCollection.DiscussGroupInfoNotify)) .Cast <int>() .ToList() .Contains(messageType)) { var groupMsg = MsgConverter.ReceiveGroupMsgEntity(messageType, mqArray, ref eventType, ref errorMsg); if (groupMsg == null) { continue; } groupMsg.MsgType = eventType; contentobjList.Add(groupMsg); } //其他信息接收:[其他的信息]MsgReceipt、MultiTerminalSynch、PointFileAccepted、PointBurnReaded、VersionHardUpdate、OrganizationModify、UnvarnishedMsg // [讨论组信息]UnReadNotifications、AddNotification、DeleteNotification、ModifyNotificationState if (Enum.GetValues(typeof(SdkEnumCollection.OtherMsgType)).Cast <int>().ToList().Contains(messageType) || Enum.GetValues(typeof(SdkEnumCollection.NotificationMsgType)) .Cast <int>() .ToList() .Contains(messageType)) { var otherMsg = MsgConverter.ReceiveOtherMsgEntity(messageType, mqArray, ref eventType, ref errorMsg); if (otherMsg == null) { continue; } otherMsg.MsgType = eventType; contentobjList.Add(otherMsg); } //后续确认合并处理 if (messageType >= 4000 && messageType <= 9999) { //自定义消息或透传消息 var otherMsg = MsgConverter.ReceiveOtherMsgEntity(messageType, mqArray, ref eventType, ref errorMsg); if (otherMsg == null) { continue; } otherMsg.MsgType = eventType; contentobjList.Add(otherMsg); } } if (contentobjList.Count == 0) { return; } msReceived?.Invoke(SdkMsgType.OffLineMessage, contentobjList); }