XMPP 1对1聊天查询?

发布于 2024-11-30 00:01:14 字数 269 浏览 0 评论 0原文

我正在使用 Openfire 开发一个聊天项目。

我已经完成了群聊。

但混乱在于一对一的聊天。

我正在使用:

<message from='user2@server/user2' to='user1@server/user1' type='chat'>

<body>TEST< /body>

</message>

但它不发送它。

提前致谢。

I am developing a chat project using Openfire.

I have done with group chatting.

But confusion is in 1 to 1 chat.

I am using:

<message from='user2@server/user2' to='user1@server/user1' type='chat'>

<body>TEST< /body>

</message>

but it does not send it.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我不是你的备胎 2024-12-07 00:01:14

假设 < 字符后面不应该有空格,它看起来是正确的。

您甚至可以不使用 from 属性,因为它将由服务器添加。

Assuming that the spaces after the < characters shouldn't be there, it looks correct.

You can even do without the from attribute, since it'll be added by the server.

凡尘雨 2024-12-07 00:01:14
- (AppDelegate *)appDelegate
{
    return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}
- (XMPPStream *)xmppStream
{
    return [[self appDelegate] xmppStream];
}

 - (void)sendMessage:(id)sender
{   

    NSString *messageStr =messageField.text;
    if([messageStr length] > 0)
    {

         NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
        [body setStringValue:messageStr];
         NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
        [message addAttributeWithName:@"type" stringValue:@"chat"];
        [message addAttributeWithName:@"to" stringValue:@"destination email address"];
        [message addChild:body];
         NSLog(@"%@",message);

        [[self xmppStream] sendElement:message];
    }
}

当您单击发送按钮时,将调用此方法并将日志消息显示为

<message type="chat" to="destination email address"><body>messageStr</body></message>
- (AppDelegate *)appDelegate
{
    return (AppDelegate *)[[UIApplication sharedApplication] delegate];
}
- (XMPPStream *)xmppStream
{
    return [[self appDelegate] xmppStream];
}

 - (void)sendMessage:(id)sender
{   

    NSString *messageStr =messageField.text;
    if([messageStr length] > 0)
    {

         NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
        [body setStringValue:messageStr];
         NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
        [message addAttributeWithName:@"type" stringValue:@"chat"];
        [message addAttributeWithName:@"to" stringValue:@"destination email address"];
        [message addChild:body];
         NSLog(@"%@",message);

        [[self xmppStream] sendElement:message];
    }
}

when you click on send button this method will be called and it shows log message as

<message type="chat" to="destination email address"><body>messageStr</body></message>
九公里浅绿 2024-12-07 00:01:14

修复语法问题、删除 from 地址并从 to 地址中删除可疑正确的资源后,您将得到:

<message to='user1@server' type='chat'>
  <body>TEST</body>
</message>

上的资源 解决就像这个问题。请阅读 XEP-0296 了解在执行 XMPP IM 时如何正确处理资源。

After fixing the syntax issues, removing the from address, and removing the doubtfully-correct resource from the to address, you're left with:

<message to='user1@server' type='chat'>
  <body>TEST</body>
</message>

The resource on the to address is like the issue. Read XEP-0296 for how to deal with resources correctly when doing XMPP IM.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文