NAME

Net::XMPP2::Ext::MUC - Implements XEP-0045: Multi-User Chat

SYNOPSIS

my $con = Net::XMPP2::Connection->new (...);
$con->add_extension (my $disco = Net::XMPP2::Ext::Disco->new);
$con->add_extension (
   my $muc = Net::XMPP2::Ext::MUC->new (disco => $disco, connection => $con)
);
...

DESCRIPTION

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 Net::XMPP2::Ext::Disco extension for service discovery.

METHODS

new

This is the constructor for a pubsub object. It takes no further arguments.

is_conference ($jid, $cb)

TODO

is_room ($jid, $cb)

This method sends a information discovery to the $jid. $cb is called when the information arrives or with an error after the usual IQ timeout.

When the $jid was a room $cb is called with the first argument being a Net::XMPP2::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 Net::XMPP2::Error::IQ object.

join_room ($jid, $nick, $cb, %args)

This method joins a room.

$jid should be the bare jid of the room. $nick should be your desired nickname in the room.

$cb is called upon successful entering the room or if an error occured. If a error occured the first argument is a Net::XMPP2::Error::MUC object. If the join was successful the first argument is undef.

%args hash can contain one of the following keys:

timeout => $timeout_in_secs

The default timeout is 60 seconds if the timeout is not specified.

get_room ($jid)

This returns the Net::XMPP2::Ext::MUC::Room object for the bare part of the $jid if we are joining or have joined such a room.

If we are not joined undef is returned.

is_connected

This returns whether we are still connected and can send messages.

EVENTS

All events from Net::XMPP2::Ext::MUC::Room instances that were joined with this MUC are forwarded to this object. The events from the room are prefixed with 'room_' and the first argument is always the Net::XMPP2::Connection the MUC operates on, the second is always the Net::XMPP2::Ext::MUC::Room object and the rest of the argument corresponds to the arguments of the event of the room. See the event description for Net::XMPP2::Ext::MUC::Room for details which events are generated. Generally, if you want for example to get the joined event:

$muc->reg_cb (room_enter => sub {
   my ($muc, $con, $room) = @_;
   # ...
});

These additional events can be registered on with reg_cb:

AUTHOR

Robin Redeker, <elmex at ta-sa.org>, JID: <elmex at jabber.org>

COPYRIGHT & LICENSE

Copyright 2007 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.