Net-Async-Matrix
view release on metacpan or search on metacpan
The following events are invoked, either using subclass methods or CODE
references in parameters:
on_log $message
A request to write a debugging log message. This is provided
temporarily for development and debugging purposes, but will at some
point be removed when the code has reached a certain level of
stability.
on_presence $user, %changes
Invoked on receipt of a user presence change event from the homeserver.
%changes will map user state field names to 2-element ARRAY references,
each containing the old and new values of that field.
on_room_new $room
Invoked when a new room first becomes known about.
Passed an instance of Net::Async::Matrix::Room.
on_room_del $room
Invoked when the user has now left a room.
on_invite $event
Invoked on receipt of a room invite. The $event will contain the plain
Matrix event as received; with at least the keys inviter and room_id.
on_unknown_event $event
Invoked on receipt of any sort of event from the event stream, that is
not recognised by any of the other code. This can be used to handle new
kinds of incoming events.
PARAMETERS
The following named parameters may be passed to new or configure. In
addition, CODE references for event handlers using the event names
listed above can also be given.
server => STRING
Hostname and port number to contact the homeserver at. Given in the
form
$hostname:$port
This string will be interpolated directly into HTTP request URLs.
SSL => BOOL
Whether to use SSL/TLS to communicate with the homeserver. Defaults
false.
SSL_* => ...
Any other parameters whose names begin SSL_ will be stored for passing
to the HTTP user agent. See IO::Socket::SSL for more detail.
path_prefix => STRING
Optional. Gives the path prefix to find the Matrix client API at.
Normally this should not need modification.
on_room_member, on_room_message => CODE
Optional. Sets default event handlers on new room objects.
enable_events => BOOL
Optional. Normally enabled, but if set to a defined-but-false value
(i.e. 0 or empty string) the event stream will be disabled. This will
cause none of the incoming event handlers to be invoked, because the
server will not be polled for events.
This may be useful in simple send-only cases where the client has no
interest in receiveing any events, and wishes to reduce the load on the
homeserver.
longpoll_timeout => NUM
Optional. Timeout in seconds for the /events longpoll operation.
Defaults to 30 seconds if not supplied.
first_sync_limit => NUM
Optional. Number of events per room to fetch on the first /sync request
on startup. Defaults to the server's builtin value if not defined,
which is likely to be 10.
METHODS
The following methods documented with a trailing call to ->get return
Future instances.
login
$matrix->login( %params )->get
Performs the necessary steps required to authenticate with the
configured Home Server, actually obtain an access token and starting
the event stream (unless disabled by the enable_events option being
false). The returned Future will eventually yield the $matrix object
itself, so it can be easily chained.
There are various methods of logging in supported by Matrix; the
following sets of arguments determine which is used:
user_id, password
Log in via the m.login.password method.
user_id, access_token
Directly sets the user_id and access_token fields, bypassing the
usual login semantics. This presumes you already have an existing
access token to re-use, obtained by some other mechanism. This exists
largely for testing purposes.
( run in 2.386 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )