NAME
Net::XMPP2::Ext::MUC::Room - Room class
SYNOPSIS
DESCRIPTION
This module represents a room handle for a MUC.
METHODS
- new (%args)
- get_user ($nick)
-
This method returns the user with the
$nickin the room. - get_me
-
This method returns the Net::XMPP2::Ext::MUC::User object of yourself in the room. If will return undef if we are not in the room anymore.
- get_user_jid ($jid)
-
This method looks whether a user with the JID
$jidexists in the room. That means whether the node and domain part of the JID match the rooms node and domain part, and the resource part of the JID matches a joined nick. - get_users
-
This method returns the list of occupants as Net::XMPP2::Ext::MUC::User objects.
- make_instant ($cb)
-
If you just created a room you can create an instant room with this method instead of going through room configuration for a reserved room.
If you want to create a reserved room instead don't forget to unset the
create_instantargument of thejoin_roommethod of Net::XMPP2::Ext::MUC!See also the
request_configurationmethod below for the reserved room config.$cbis the callback that will be called when the instant room creation is finished. If successful the first argument will be this room object ($self), if unsuccessful the first argument will be undef and the second will be a Net::XMPP2::Error::IQ object. - request_configuration ($cb)
-
This method requests the room configuration. When the configuration form or an error arrives
$cbwill be called. The first argument to the callback will be a Net::XMPP2::Ext::DataForm with the room configuration form or undef in case of an error. The second argument will be a Net::XMPP2::Error::MUC error object if an error occured or undef if no error occured.If you made an answer form you can send it via the
send_configurationmethod below.Here is an example:
$room->request_configuration (sub { my ($form, $err) = @_; $form or return; my $af = Net::XMPP2::Ext::DataForm->new; $af->make_answer_form ($form); $af->set_field_value ('muc#roomconfig_maxusers', 20); $af->clear_empty_fields; $roomhdl->send_configuration ($af, sub { # ... }); }); send_configuration ($answer_form, $cb)-
This method sends the answer form to a configuration request to the room.
$answer_formshould be a Net::XMPP2::Ext::DataForm object containig the answer form with the changed configuration.The first argument of
$cbwill be a true value if the configuration change was successful. The second argument of$cbwill be aNet::XMPP2::Error::IQobject if the configuration change was not successful. - make_message (%args)
-
This method constructs a Net::XMPP2::Ext::MUC::Message with a connection to this room.
%argsare further arguments for the constructor of Net::XMPP2::Ext::MUC::Message. The defaulttoargument for the message is the room and thetypewill be 'groupchat'. - send_part ($msg, $cb, $timeout)
-
This lets you part the room,
$msgis an optional part message and can be undef if no custom message should be generated.$cbis called when we successfully left the room or after$timeoutseconds. The default for$timeoutis 60.The first argument to the call of
$cbwill be undef if we successfully parted, or a true value when the timeout hit. Even if we timeout we consider ourself parted. - users
-
Returns a list of Net::XMPP2::Ext::MUC::User objects which are in this room.
- jid
-
Returns the bare JID of this room.
- nick_jid
-
Returns the full JID of yourself in the room.
- is_connected
-
Returns true if this room is still connected (but maybe not joined (yet)).
- is_joined
-
Returns true if this room is still joined (and connected).
- change_nick ($newnick)
-
This method lets you change your nickname in this room.
- change_subject ($newsubject)
-
This methods changes the subject of the room.
EVENTS
These events can be registered on with reg_cb:
- message => $msg, $is_echo
-
This event is emitted when a message was received from the room.
$msgis a Net::XMPP2::Ext::MUC::Message object and$is_echois true if the message is an echo. - subject_change => $msg, $is_echo
-
This event is emitted when a user changes the room subject.
$msgis a Net::XMPP2::Ext::MUC::Message object and$is_echois true if the message is an echo.The room subject is the subject of that
$msg. - subject_change_error => $error
-
If you weren't allowed to change the subject or some other error occured you will receive this event.
$erroris a Net::XMPP2::Error::MUC object. - error => $error
-
This event is emitted when any error occured.
$erroris a Net::XMPP2::Error::MUC object. - join_error => $error
-
This event is emitted when a error occured when joining a room.
$erroris a Net::XMPP2::Error::MUC object. - enter => $user
-
This event is emitted when we successfully joined the room.
$useris a Net::XMPP2::Ext::MUC::User object which is the user handle for ourself. - join => $user
-
This event is emitted when a new user joins the room.
$useris the Net::XMPP2::Ext::MUC::User object of that user. - nick_change => $user, $oldnick, $newnick
-
This event is emitted when a user changed his nickname.
$useris the Net::XMPP2::Ext::MUC::User object of that user.$oldnickis the old nickname and$newnickis the new nickname. - presence => $user
-
This event is emitted when a user changes it's presence status (eg. affiliation or role, or away status).
$useris the Net::XMPP2::Ext::MUC::User object of that user. - part => $user
-
This event is emitted when a user leaves the channel.
$useris the Net::XMPP2::Ext::MUC::User of that user, but please note that you shouldn't send any messages to this user anymore. - leave
-
This event is emitted when we leave the room.
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.