BGIMMsgHandler.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // BGIMMsgHandler.h
  3. // BugoLive
  4. //
  5. // Created by xfg on 16/11/24.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. // IM消息监听
  8. #import <Foundation/Foundation.h>
  9. #import "AVIMRunLoop.h"
  10. #import "BGLiveBaseController.h"
  11. #import "MGGlobalVipView.h"
  12. #import <ImSDK_Plus/ImSDK_Plus.h>
  13. @class BGIMMsgHandler;
  14. @protocol FWIMMsgListener <NSObject>
  15. @required
  16. // 收到自定义C2C消息
  17. - (void)onIMHandler:(BGIMMsgHandler *)receiver recvCustomC2C:(id<AVIMMsgAble>)msg;
  18. // 收到自定义的Group消息
  19. - (void)onIMHandler:(BGIMMsgHandler *)receiver recvCustomGroup:(id<AVIMMsgAble>)msg;
  20. @end
  21. @interface BGIMMsgHandler : NSObject<TIMMessageListener,V2TIMSDKListener,V2TIMGroupListener>
  22. {
  23. @protected
  24. __weak AVIMRunLoop *_sharedRunLoopRef; // 消息处理线程的引用
  25. NSMutableDictionary *_msgCache; // 以key为id<AVIMMsgAble> msgtype的, value不AVIMCache,在runloop线程中执行
  26. OSSpinLock _msgCacheLock;
  27. NSMutableArray *_newMsgMArray; // 获取到的缓存消息列表
  28. GlobalVariables *_BuguLive;
  29. __weak id<FWShowLiveRoomAble> _liveItem;
  30. }
  31. @property (nonatomic, weak) id<FWIMMsgListener> iMMsgListener;
  32. @property (nonatomic, strong)V2TIMConversation *chatRoomConversation; // 群会话上下文
  33. // 运行过程中,如果先是YES,再置为NO,设置前使用者注意将_msgCache的取出,内部自动作清空处理
  34. @property (nonatomic, assign) BOOL isCacheMode; // 是否是缓存模式
  35. @property (nonatomic, assign) BOOL isEnterRooming; // 是否正在进入直播间
  36. @property (nonatomic, assign) BOOL isExitRooming; // 是否正在退出直播间
  37. @property (nonatomic, assign) BOOL isCurrentInSDK; // 当前已经进入了SDK
  38. @property (nonatomic, assign) BOOL isEnterSDKing; // 是否正在进入SDK
  39. @property (nonatomic, assign) BOOL isExitSDKing; // 是否正在退出SDK
  40. @property(nonatomic, strong) MGGlobalVipView *globalView;//广播视图
  41. @property(nonatomic, strong) UIWindow *window;
  42. // 单例模式
  43. BogoSingletonH(Instance);
  44. // 从缓存中取出maxDo条数据处理
  45. - (void)onHandleMyNewMessage:(NSInteger)maxDo;
  46. // 发送自定义一对一消息
  47. - (void)sendCustomC2CMsg:(SendCustomMsgModel *)sCMM succ:(TIMSucc)succ fail:(TIMFail)fail;
  48. // 发送自定义群消息
  49. - (void)sendCustomGroupMsg:(SendCustomMsgModel *)sCMM succ:(TIMSucc)succ fail:(TIMFail)fail;
  50. - (void)sendCustomC2CMsg:(SendCustomMsgModel *)sCMM widthPID:(NSString *)pid succ:(TIMSucc)succ fail:(TIMFail)fail;
  51. -(void)showGlobalViewWithModel:(CustomMessageModel *)customMessageModel;
  52. @end
  53. // 供子类重写
  54. @interface BGIMMsgHandler (ProtectedMethod)
  55. - (id<IMUserAble>)syncGetC2CUserInfo:(NSString *)identifier;
  56. - (void)onRecvC2CSender:(id<IMUserAble>)sender customMsg:(V2TIMCustomElem *)msg textMsg:(NSString *)textMsg;
  57. - (void)onRecvGroupSender:(id<IMUserAble>)sender groupId:(NSString *)groupId customMsg:(V2TIMCustomElem *)msg textMsg:(NSString *)textMsg;
  58. - (void)onRecvSystepGroupSender:(id<IMUserAble>)sender groupId:(NSString *)groupId customMsg:(V2TIMGroupTipsElem *)msg textMsg:(NSString *)textMsg;
  59. @end
  60. @interface BGIMMsgHandler (CacheMode)
  61. // 用户通过设置此方法,监听要处理的消息类型
  62. - (void)createMsgCache;
  63. - (void)resetMsgCache;
  64. - (void)releaseMsgCache;
  65. // 如果cache不成功,会继续上报
  66. - (void)enCache:(id<AVIMMsgAble>)msg noCache:(FWVoidBlock)noCacheblock;
  67. - (NSDictionary *)getMsgCache;
  68. @end
  69. // 互动直播间的加入、退出操作(已废弃)
  70. @interface BGIMMsgHandler (LivingRoom)
  71. // 设置群聊监听
  72. - (void)setGroupChatListener:(id<FWShowLiveRoomAble>)liveItem block:(CommonBlock)block;
  73. // 移除群聊监听
  74. - (void)removeGroupChatListener;
  75. @end