plutodai的专栏

首先需要创建一个房间:

xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:self jid:[XMPPJID jidWithString:[NSString stringWithFormat:@"%@@%@", jidString, @"conference.192.168.1.117"]]];[xmppRoom activate:xmppStream];[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];

加入房间:

[[self xmppRoom] joinRoomUsingNickname:[[[NSUserDefaults standardUserDefaults] objectForKey:@"UserInfo"] valueForKey:@"userId"] history:nil];此时房间ID就出现在好友列表内,可以正常进入聊天。

其次邀请好友:

[[self xmppRoom] inviteUser:[XMPPJID jidWithString:[NSString stringWithFormat:@"%@@192.168.1.117", friendIDFeild.text]] withMessage:@"join room!"];客户端要对收到邀请做出响应,,方法如下:

新建一个XMPPMUC:

xmppMUC = [[XMPPMUC alloc] initWithDispatchQueue:dispatch_get_main_queue()];[xmppMUC activate:xmppStream];[xmppMUC addDelegate:self delegateQueue:dispatch_get_main_queue()];类要实现XMPPMUCDelegate-(void)xmppMUC:(XMPPMUC *)sender roomJID:(XMPPJID *)roomJID didReceiveInvitation:(XMPPMessage *)message{NSLog(@"%@", message);xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:self jid:roomJID];[xmppRoom activate:xmppStream];[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];[xmppRoom joinRoomUsingNickname:[[[NSUserDefaults standardUserDefaults] objectForKey:@"UserInfo"] valueForKey:@"userId"] history:nil];}其中[xmppRoom joinRoomUsingNickname:[[[NSUserDefaults standardUserDefaults] objectForKey:@"UserInfo"] valueForKey:@"userId"] history:nil];为确认加入房间。

当你接受请求后,房间id会出现在联系人列表中,正常聊天就可以了,聊天信息的type为groupchat,这部分在XMPP基础中有,不做赘述。此为初步,后续补充。

走过一段路,风景毕竟不相同。这段惠风和畅,

plutodai的专栏

相关文章:

你感兴趣的文章:

标签云: