码迷,mamicode.com
首页 > 其他好文 > 详细

xmpp聊天室(5)

时间:2014-05-04 11:06:05      阅读:345      评论:0      收藏:0      [点我收藏+]

标签:blog   class   tar   color   width   get   

聊天室

 

  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. }  

xmpp聊天室(5),布布扣,bubuko.com

xmpp聊天室(5)

标签:blog   class   tar   color   width   get   

原文地址:http://www.cnblogs.com/yulang314/p/3705605.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!