就我而言,我需要同时使用两个答案并定义 self like
@interface XMPPDelegate : NSObject <XMPPMUCDelegate>
激活 XMPPMUC 协议如下:
XMPPMUC * xmppMUC = [[XMPPMUC alloc]
initWithDispatchQueue:dispatch_get_main_queue()];
[xmppMUC activate:_xmppStream];
[xmppMUC addDelegate:self delegateQueue:dispatch_get_main_queue()];
接收加入消息:
- (void)xmppMUC:(XMPPMUC *)sender roomJID:(XMPPJID *) roomJID didReceiveInvitation:(XMPPMessage *)message
{
DDLogDebug(@"%@", message);
XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:roomMemoryStorage jid:roomJID dispatchQueue:dispatch_get_main_queue()];
[xmppRoom activate:xmppStream];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom joinRoomUsingNickname: xmppStream.myJID.user history:nil password:password];
XMPPPresence *presence = [XMPPPresence presence];
[[self xmppStream] sendElement:presence];
[xmppRoster addUser:roomJID withNickname:roomJID.full];
[self goOnline];
}