XMPP持久的会议室存在

时间:2012-11-21 14:14:40

标签: xmpp

我有一堆XMPP服务器(openfire),其中包含一组客户端(spark),分为几个组(部门)。我正在寻找将他们留在会议室的能力。我指的是Skype类似的功能;当用户通过群组对话关闭窗口时,他的客户端会跟踪该会议室的活动,当新消息出现时,用户自动再次加入该会议。我已经发现在spark + openfire中没有这样的能力,虽然有自动加入的漂亮的群聊书签功能,但它不会阻止用户只是离开房间而不能注意到其他事件。我想问一下是否有任何XMPP客户端实现了这个功能。 我发现我可以设置我自己的机器人,拥有管理权限,可以坐在每个房间,并可能使用户在离开会议时强制踢/重新连接(例如通过openfire管理,通过HTTP功能)并且他没有结束会话,所以连接上的自动加入会让他回来。但是,如果有替代方案,我认为简单地更改客户端应用程序会更容易也更好。

更新:我刚刚在spark中找到了“auto accept invite to group chats”选项,所以如果我在他们不知情的情况下重新配置所有客户端并设置这个机器人只需发送邀请,如果该人离开了频道就应该这样做。还有其他想法吗?

UPDATE2:

好的,大家好,我已成功测试了“Spark->偏好设置 - >群组聊天 - >自动接受群聊邀请”选项,它正在运行;我的火花加入我自动邀请的每个会议。所以我实施了会议观看 - >基于JAXL 3.0的bot中的auto reinvite功能。唯一的问题是jaxl-sent邀请对我不起作用。 这是源代码:

<?php
###  JAXL message bot composed by ewilded
require 'JAXL-3.x/jaxl.php';
$jabber_conf=array('jid' => 'messagebot@localhost','host'=>'openfire','user'=>'messagebot','domain'=>'localhost','logLevel'=>4, 'strict'=>true, 'port'=>5222, 'pass'=>'somepass','log_level' => JAXL_INFO);
error_reporting(E_ALL);
$conference_rooms=array('tech@conference.localhost');
$client=null;

## Creating the object
$client = new JAXL($jabber_conf);
$client->require_xep(array(
      '0045', // MUC
      '0203', // Delayed Delivery
      '0199',  // XMPP Ping
      '0249'    // direct invite
));
## connect up callbacks
$client->add_cb('on_auth_success', function() use($client,$conference_rooms,$cron_interval) {
        echo "Auth success.\n";
    echo "My full jid: ".$client->full_jid->to_string()."\n";
        $client->set_status("Mesasge bot - available!");  // set your status
        $client->get_vcard();               // fetch your vcard
        $client->get_roster();              // fetch your roster list
        foreach($conference_rooms as $conference)
        {
            echo "Joining conference $conference.\n";
            $room_full_jid=new XMPPJid("$conference/messagebot");
            $client->xeps['0045']->join_room($room_full_jid);
       }
    });
$client->add_cb('on_chat_message', function($msg) use($client) {
            $to=$msg->from; 
          echo "Sending answer to: ".$to."\n";
            $client->send_chat_msg($to,"I am just simple bot written in PHP with JAXL XMPP library.");
        });
$client->add_cb('on_connect_error',function(){echo "Connection error :(\n";});
$client->add_cb('on_disconnect', function() {
     echo "Got disconnected.\n";
     _debug("got on_disconnect cb");
});

$client->add_cb('on_error_stanza',function($msg)
{    
    echo "Error stanza.";
    #print_r($msg);  
});
$client->add_cb('on_presence_stanza',function($msg) use($client)
{
    echo "Presence stanza.\n";
    ### joins and lefts are shown here, so here we simply send reinvite if we see that someone's left
    if(isset($msg->attrs['type'])&&$msg->attrs['type']=='unavailable')
    {
        if(isset($msg->childrens[0])&&isset($msg->childrens[0]->childrens[0])&&isset($msg->childrens[0]->childrens[0]->attrs['jid']))
        {
            echo "Sending invite.\n";
            $jid=$msg->childrens[0]->childrens[0]->attrs['jid'];
            $bare_jid=explode("/",$jid);
            $from_room=$msg->attrs['from'];
            $bare_from_room=explode("/",$from_room);
            echo $bare_jid[0]."\n";
            echo $bare_from_room[0]."\n";
            $client->xeps['0249']->invite($jid,$from_room); ### for some reason it does not work :(
            echo "Invite ($jid to $from_room) sent.\n";
        }
        else
        {
            echo "Ignoring.\n";
        }
    }
    echo "After presence stanza.\n";
});
$client->add_cb('on_normal_stanza',function()
{
    echo "Normal stanza.\n"; 
});
$client->add_cb('on_groupchat_message',function($msg) use ($client) {
echo "Groupchat event received.\n";
});

echo "Start called.\n";
$client->start();
?>

会议室有“允许其他人邀请他人”选项,两个帐户(我的朋友在工作时发送给我的邀请和messagebot使用的帐户)都是Tech组的成员,没有他们有管理权限,所以我确定这不是设置/权限相关的问题。

现在,当我离开会议室时,机器人检测到它并向我发送邀请,这是它在输出中的样子: ...     存在节。     发送邀请。     ewilded @本地     tech@conference.localhost     发送邀请(ewilded @ localhost / Spark 2.6.3到tech@conference.localhost/Ewil Ded)。     在存在节之后。 ... 不幸的是,这个邀请没有生效。我想我正在做xep调用的错误,或者更确切地说是它的参数:     $客户端 - &GT; xeps [ '0249'] - &GT;邀请($ JID,$ from_room);

如果有人在Jaxl中有工作邀请,请帮助,这是唯一需要做的工作。

1 个答案:

答案 0 :(得分:2)

您是否在日志中看到邀请包被发送出去了?

对于下一级调试,您可能希望直接调用$invite_pkt = $client->xeps['0249']->get_invite_pkt($to_bare_jid, $room_jid)$to_bare_jid$room_jid都必须作为字符串传递。 get_invite_pkt会根据direct MUC invitation xmpp extension返回需要发送的必要节。如果您看到返回的节完全一致,只需通过调用$client->send($invite_pkt)发送即可。

希望这可以帮助您更好地进行调试并解决问题。

相关问题