【问题标题】:stanzajs send simple message to groupchatstanzajs 向群聊发送简单的消息
【发布时间】:2021-02-22 19:15:49
【问题描述】:

我正在尝试实现简单的 stanzajs 群聊,但在测试中它不清楚 from 和 to 变量。

test('MUC chat', () => {
    const client = createClient({});

    const incoming: ReceivedMessage = {
        body: 'yayyyy',
        from: 'room@rooms.test/member',
        to: 'tester@localhost',
        type: 'groupchat'
    };

    client.on('groupchat', msg => {
        expect(msg).toStrictEqual(incoming);
    });

    client.emit('message', incoming);
});

https://github.com/legastero/stanza/blob/master/test/muc/messages.ts 没有错误,但其他用户和房间看不到该消息。如何向房间发送公共消息。我不明白为什么:变量是用户而不是房间名称

this.client.on('groupchat', msg => {
    console.log("groupchat new")
    console.log(msg)
});

【问题讨论】:

    标签: xmpp ejabberd stanza.io


    【解决方案1】:

    只有加入房间的帐户(房间中的住户)才能向房间发送消息。

    您应该安装一个众所周知的 Jabber/XMPP 客户端,例如 Gajim、Psi、Tkabber...这些客户端有一个“XML 控制台”,可以让您查看它们发送和接收的节。

    将他们发送的内容与您发送的内容进行比较,您会发现问题。

    【讨论】:

      猜你喜欢
      • 2017-12-03
      • 2011-08-22
      • 2021-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-18
      • 2017-09-27
      • 1970-01-01
      相关资源
      最近更新 更多