无法使用xmpp接收群组消息

时间:2016-12-08 12:01:22

标签: ios xmpp xmppframework chatroom groupchat

我无法接收有关此方法的群组消息。

- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message
{
   NSLog(@"Message received description === %@",[message description]);
}

-(void)sendGroupMessage:(NSString *)NameOfGroup :(NSString *)Msg
{
    [xmppRoom sendMessageWithBody:Msg];
    NSXMLElement *x = [NSXMLElement elementWithName:NameOfGroup xmlns:XMPPMUCNamespace];

    XMPPMessage *message = [XMPPMessage message];
    [message addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"%@",NameOfGroup]];
    [message addChild:x];
    NSLog(@"x in Invite === %@",x);
    [xmppRoom sendMessage:message];

}

-(void)setUpRoom:(NSString *)ChatRoomJID
{

    NSString *Strng=[NSString stringWithFormat:@"Abc@conference.localhost"];
    ChatRoomJID=Strng;
    XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];

    XMPPJID *roomJID = [XMPPJID jidWithString:ChatRoomJID];

    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:self.UserID
                            history:nil
                           password:nil];

    [self performSelector:@selector(ConfigureNewRoom:) withObject:nil afterDelay:4];

}

首先,我创建新组,发送邀请并成功接受所有受邀用户。 当我在该组上发送消息时,所有人都成功收到消息,但是如果我将停止App并再次运行并使用xmpp登录并在组上发送消息,则消息不会传递给加入的用户。

当我必须注销并再次登录到xmpp服务器并在先前创建的组上发送消息时,我收到此错误消息

<message xmlns="jabber:client" from="dharmraj123@conference.localhost" to="revoz1wwbzji1e1481005747@localhost/1824017799289652742921131" type="error"><body>1 Message</body><error code="406" type="modify"><not-acceptable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></not-acceptable><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Only occupants are allowed to send messages to the conference</text></error></message>

0 个答案:

没有答案