1

我在我的服务中使用 openfire 作为聊天服务器。当对话者开始或停止在聊天中输入消息时,我需要通知用户。

我添加自定义消息类型 notification_chat 并发送带有或不带正文的附加消息:

当用户开始输入时:

<message id="SD4Vy-8" to="682@server.com" type="notification_chat"><composing xmlns="http://jabber.org/protocol/chatstates"/></message>

当用户停止输入时:

<message id="SD4Vy-9" to="682@server.com" type="notification_chat"><paused xmlns="http://jabber.org/protocol/chatstates"/></message>

但是在发送这个数据包后,openfire 会关闭连接!尽管这条消息已发送给收件人,但我可以按类型和附加信息处理它。

为什么openfire踢我是这种情况?

4

1 回答 1

5

你被踢是因为你违反了 XMPP 规范。不允许向消息添加新类型。您只能使用 RFC 中定义的类型(正常、聊天、群聊、标题、错误)。当您需要自定义信息时,然后在您自己的命名空间中添加您自己的标签来发送消息。

例子:

<message>
   <x xmlns="http://www.mycompany.com/extension1">
     <messagetype>notification_chat</messagetype>
   </x>
</message>
于 2013-04-02T07:12:31.113 回答