• xmpp聊天室(5)


    聊天室

    1. //初始化聊天室  
    2. XMPPJID *roomJID = [XMPPJID jidWithString:ROOM_JID];    
    3.     
    4. xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:self jid:roomJID];    
    5.     
    6. [xmppRoom activate:xmppStream];    
    7. [xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];  
    1. //创建聊天室成功  
    2. - (void)xmppRoomDidCreate:(XMPPRoom *)sender  
    3. {  
    4.     DDLogInfo(@"%@: %@", THIS_FILE, THIS_METHOD);  
    5. }  




    1. //加入聊天室,使用昵称  
    2. [xmppRoom joinRoomUsingNickname:@"quack" history:nil];   
    1. //获取聊天室信息  
    2. - (void)xmppRoomDidJoin:(XMPPRoom *)sender  
    3. {  
    4.     [xmppRoom fetchConfigurationForm];  
    5.     [xmppRoom fetchBanList];  
    6.     [xmppRoom fetchMembersList];  
    7.     [xmppRoom fetchModeratorsList];  
    8. }  

    如果房间存在,会调用委托

    1. // 收到禁止名单列表    
    2. - (void)xmppRoom:(XMPPRoom *)sender didFetchBanList:(NSArray *)items;    
    3. // 收到好友名单列表    
    4. - (void)xmppRoom:(XMPPRoom *)sender didFetchMembersList:(NSArray *)items;    
    5. // 收到主持人名单列表    
    6. - (void)xmppRoom:(XMPPRoom *)sender didFetchModeratorsList:(NSArray *)items;   

    房间不存在,调用委托

    1. - (void)xmppRoom:(XMPPRoom *)sender didNotFetchBanList:(XMPPIQ *)iqError;    
    2. - (void)xmppRoom:(XMPPRoom *)sender didNotFetchMembersList:(XMPPIQ *)iqError;    
    3. - (void)xmppRoom:(XMPPRoom *)sender didNotFetchModeratorsList:(XMPPIQ *)iqError;  


    离开房间

    1. [xmppRoom deactivate:xmppStream];    
    1. //离开聊天室  
    2. - (void)xmppRoomDidLeave:(XMPPRoom *)sender  
    3. {  
    4.     DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);  
    5. }  

    其他代理

      1. //新人加入群聊  
      2. - (void)xmppRoom:(XMPPRoom *)sender occupantDidJoin:(XMPPJID *)occupantJID  
      3. {  
      4.     DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);  
      5. }  
      6. //有人退出群聊  
      7. - (void)xmppRoom:(XMPPRoom *)sender occupantDidLeave:(XMPPJID *)occupantJID  
      8. {  
      9.     DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);  
      10. }  
      11. //有人在群里发言  
      12. - (void)xmppRoom:(XMPPRoom *)sender didReceiveMessage:(XMPPMessage *)message fromOccupant:(XMPPJID *)occupantJID  
      13. {  
      14.     DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);  
      15. }  
  • 相关阅读:
    Soldier and Number Game素数筛
    HDU1501Zipper字符串的dfs
    HDU1285 确定比赛名次 拓扑排序模板题
    HDU1595 find the longest of the shortest dijkstra+记录路径
    HDU1556 Color the ball 前缀和/线段树/树状数组
    Function Run Fun递归+细节处理
    数学公式
    日常 java+雅思+训练题1
    HDU1423Greatest Common Increasing Subsequence
    HDU1595find the longest of the shortestdijkstra+记录路径
  • 原文地址:https://www.cnblogs.com/yulang314/p/3705605.html
Copyright © 2020-2023  润新知