AnyEvent::XMPP::Ext::MUC(3pm) | User Contributed Perl Documentation | AnyEvent::XMPP::Ext::MUC(3pm) |
AnyEvent::XMPP::Ext::MUC - Implements XEP-0045: Multi-User Chat
my $con = AnyEvent::XMPP::Connection->new (...); $con->add_extension (my $disco = AnyEvent::XMPP::Ext::Disco->new); $con->add_extension (my $muc = AnyEvent::XMPP::Ext::MUC->new (disco => $disco)); ...
This module handles multi user chats and provides new events to catch multi user chat messages. It intercepts messages from the connection so they don't interfere with your other callbacks on the connection.
This extension requires the AnyEvent::XMPP::Ext::Disco extension for service discovery.
When the $jid was a room $cb is called with the first argument being a AnyEvent::XMPP::Ext::MUC::RoomInfo object. If the destination wasn't reachable, the room doesn't exist or some other error happened the first argument will be undefined and the second a AnyEvent::XMPP::Error::IQ object.
$con should be the AnyEvent::XMPP::IM::Connection object that is to be used to send the necessary stanzas. $jid should be the bare JID of the room. $nick should be your desired nickname in the room.
When you successfully entered the room a "enter" event is emitted. In case you created the room, and it is locked, a "locked" event is emitted. Please look in the "EVENTS" section below for more details about how to handle "locked" rooms. (You won't have to care about locked rooms if you didn't disable the "create_instant" flag in %args).
If an error occurred and we couldn't join the room, the first two arguments are undef and the third is a AnyEvent::XMPP::Error::MUC object signalling the error.
%args hash can contain one of the following keys:
Example:
history => {chars => 0} # don't load history history => {stanzas => 3} # load last 3 history elements history => {seconds => 300, chars => 500} # load history in last 5 minutes, but max 500 characters
TODO: add "since" attributes
XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
The default for this flag is true! So if you want to create an reserved room with custom creation in the beginning you have to pass a false value as $bool.
PLEASE NOTE: If you set $bool to a false value you have to check the "did_create_room" status flag on your own instance of AnyEvent::XMPP::Ext::MUC::User (provided as the second argument to the callback) to see whether you need to finish room creation! If you don't do this the room may stay LOCKED for ever.
See also the "make_instant" and "request_configuration" methods of AnyEvent::XMPP::Ext::MUC.
This function is called everytime the nickname collides on join, so you should take care of possible endless retries.
If we are not joined undef is returned.
These are the events that are issued by this MUC extension:
$room is the AnyEvent::XMPP::Ext::MUC::Room object which the event belongs to.
NOTE: Please note that some conferences send messages already before you have finished joining a room. That means that you might already get a "message" event for a room that you haven't got an "enter" for event yet. That means that methods like "get_me" might return undef.
The room subject is the subject of that $msg.
Please consult the methods "make_instant", "request_configuration" and "send_configuration" of AnyEvent::XMPP::Ext::MUC::Room for more information about how to configure a room.
NOTE: You won't get another event when you finished configuring the room, so you maybe want to call this on the "AnyEvent::XMPP::Ext::MUC" object when you finished configuring the room successfully:
$muc->event (enter => $room, $room->get_me);
That could be helpful if you want to place some generic stuff in your "enter" event handlers.
NOTE2: If you didn't disable the "create_instant" flag of "join_room" you won't have to care about a "locked" event, as everything will be internally handled for you and you will get an "enter" event if the room is finally setted up.
Robin Redeker, "<elmex at ta-sa.org>", JID: "<elmex at jabber.org>"
Copyright 2007, 2008 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2022-12-06 | perl v5.36.0 |