@@ -78,6 +78,16 @@ - (void)onReceiveMessage:(JMSGMessage *)message error:(NSError *)error{
7878 [[NSNotificationCenter defaultCenter ] postNotificationName: kJJMessageReceiveMessage object: dict];
7979}
8080
81+ - (void )onReceiveChatRoomConversation : (JMSGConversation *)conversation messages : (NSArray <__kindof JMSGMessage *> *)messages {
82+
83+ NSArray *msgDicArr = [messages mapObjectsUsingBlock: ^id (id obj, NSUInteger idx) {
84+ JMSGMessage *msg = obj;
85+ return [msg messageToDictionary ];
86+ }];
87+
88+ [[NSNotificationCenter defaultCenter ] postNotificationName: kJJMessageReceiveChatRoomMessage object: msgDicArr];
89+ }
90+
8191- (void )onReceiveNotificationEvent : (JMSGNotificationEvent *)event {
8292 switch (event.eventType ) {
8393 case kJMSGEventNotificationLoginKicked :
@@ -242,15 +252,25 @@ @implementation JMSGConversation (JMessage)
242252-(NSMutableDictionary *)conversationToDictionary {
243253 NSMutableDictionary *dict = [NSMutableDictionary dictionary ];
244254
245- if (self.conversationType == kJMSGConversationTypeSingle ) {
246- JMSGUser *user = self.target ;
247- dict[@" target" ] = [user userToDictionary ];
248- dict[@" conversationType" ] = @" single" ;
249-
250- } else {
251- JMSGGroup *group = self.target ;
252- dict[@" target" ] = [group groupToDictionary ];
253- dict[@" conversationType" ] = @" group" ;
255+ switch (self.conversationType ) {
256+ case kJMSGConversationTypeSingle :{
257+ JMSGUser *user = self.target ;
258+ dict[@" target" ] = [user userToDictionary ];
259+ dict[@" conversationType" ] = @" single" ;
260+ break ;
261+ }
262+ case kJMSGConversationTypeGroup :{
263+ JMSGGroup *group = self.target ;
264+ dict[@" target" ] = [group groupToDictionary ];
265+ dict[@" conversationType" ] = @" group" ;
266+ break ;
267+ }
268+ case kJMSGConversationTypeChatRoom :{
269+ JMSGChatRoom *chatRoom = self.target ;
270+ dict[@" target" ] = [chatRoom chatRoomToDictionary ];
271+ dict[@" conversationType" ] = @" chatRoom" ;
272+ break ;
273+ }
254274 }
255275
256276 dict[@" latestMessage" ] = [self .latestMessage messageToDictionary ];
@@ -345,12 +365,23 @@ - (NSMutableDictionary *)messageToDictionary {
345365 dict[@" extras" ] = self.content .extras ;
346366 }
347367
348- if (self.targetType == kJMSGConversationTypeSingle ) {
349- JMSGUser *user = self.target ;
350- dict[@" target" ] = [user userToDictionary ];
351- } else {
352- JMSGGroup *group = self.target ;
353- dict[@" target" ] = [group groupToDictionary ];
368+ switch (self.targetType ) {
369+ case kJMSGConversationTypeSingle : {
370+ JMSGUser *user = self.target ;
371+ dict[@" target" ] = [user userToDictionary ];
372+ break ;
373+ }
374+
375+ case kJMSGConversationTypeGroup :{
376+ JMSGGroup *group = self.target ;
377+ dict[@" target" ] = [group groupToDictionary ];
378+ break ;
379+ }
380+ case kJMSGConversationTypeChatRoom :{
381+ JMSGChatRoom *chatRoom= self.target ;
382+ dict[@" target" ] = [chatRoom chatRoomToDictionary ];
383+ break ;
384+ }
354385 }
355386
356387 dict[@" createTime" ] = self.timestamp ;
@@ -391,63 +422,63 @@ - (NSMutableDictionary *)messageToDictionary {
391422
392423 switch (eventContent.eventType ) {
393424 case kJMSGEventNotificationAcceptedFriendInvitation : {
394- dict[@" evenType " ] = @" acceptedFriendInvitation" ;
425+ dict[@" eventType " ] = @" acceptedFriendInvitation" ;
395426 break ;
396427 }
397428 case kJMSGEventNotificationAddGroupMembers : {
398- dict[@" evenType " ] = @" group_member_added" ;
429+ dict[@" eventType " ] = @" group_member_added" ;
399430 break ;
400431 }
401432 case kJMSGEventNotificationCreateGroup : {
402- dict[@" evenType " ] = @" createGroup" ;
433+ dict[@" eventType " ] = @" createGroup" ;
403434 break ;
404435 }
405436 case kJMSGEventNotificationCurrentUserInfoChange : {
406- dict[@" evenType " ] = @" currentUserInfoChange" ;
437+ dict[@" eventType " ] = @" currentUserInfoChange" ;
407438 break ;
408439 }
409440 case kJMSGEventNotificationDeclinedFriendInvitation : {
410- dict[@" evenType " ] = @" declinedFriendInvitation" ;
441+ dict[@" eventType " ] = @" declinedFriendInvitation" ;
411442 break ;
412443 }
413444 case kJMSGEventNotificationDeletedFriend : {
414- dict[@" evenType " ] = @" deletedFriend" ;
445+ dict[@" eventType " ] = @" deletedFriend" ;
415446 break ;
416447 }
417448 case kJMSGEventNotificationExitGroup : {
418- dict[@" evenType " ] = @" group_member_exit" ;
449+ dict[@" eventType " ] = @" group_member_exit" ;
419450 break ;
420451 }
421452 case kJMSGEventNotificationLoginKicked : {
422- dict[@" evenType " ] = @" loginKicked" ;
453+ dict[@" eventType " ] = @" loginKicked" ;
423454 break ;
424455 }
425456 case kJMSGEventNotificationMessageRetract : {
426- dict[@" evenType " ] = @" messageRetract" ;
457+ dict[@" eventType " ] = @" messageRetract" ;
427458 break ;
428459 }
429460 case kJMSGEventNotificationReceiveFriendInvitation : {
430- dict[@" evenType " ] = @" receiveFriendInvitation" ;
461+ dict[@" eventType " ] = @" receiveFriendInvitation" ;
431462 break ;
432463 }
433464 case kJMSGEventNotificationReceiveServerFriendUpdate : {
434- dict[@" evenType " ] = @" receiveServerFriendUpdate" ;
465+ dict[@" eventType " ] = @" receiveServerFriendUpdate" ;
435466 break ;
436467 }
437468 case kJMSGEventNotificationRemoveGroupMembers : {
438- dict[@" evenType " ] = @" group_member_removed" ;
469+ dict[@" eventType " ] = @" group_member_removed" ;
439470 break ;
440471 }
441472 case kJMSGEventNotificationServerAlterPassword : {
442- dict[@" evenType " ] = @" serverAlterPassword" ;
473+ dict[@" eventType " ] = @" serverAlterPassword" ;
443474 break ;
444475 }
445476 case kJMSGEventNotificationUpdateGroupInfo : {
446- dict[@" evenType " ] = @" updateGroupInfo" ;
477+ dict[@" eventType " ] = @" updateGroupInfo" ;
447478 break ;
448479 }
449480 case kJMSGEventNotificationUserLoginStatusUnexpected : {
450- dict[@" evenType " ] = @" userLoginStatusUnexpected" ;
481+ dict[@" eventType " ] = @" userLoginStatusUnexpected" ;
451482 break ;
452483 }
453484 default :
@@ -510,7 +541,7 @@ - (NSDictionary *)errorToDictionary {
510541@implementation JMSGChatRoom (JMessage)
511542- (NSMutableDictionary *)chatRoomToDictionary {
512543 NSMutableDictionary *dict = @{}.mutableCopy ;
513- dict[@" type" ] = @" chatroom " ;
544+ dict[@" type" ] = @" chatRoom " ;
514545 dict[@" roomId" ] = self.roomID ;
515546 dict[@" roomName" ] = self.name ;
516547 dict[@" appKey" ] = self.appkey ;
0 commit comments