The "event_id" returned by the HS is returned directly, instead of
a lone table with a single "event_id" member, for the following methods:
room:send_text()
room:send_emote()
room:send_notice()
This makes the room:get_alias_or_id() method return the shortest of the room
aliases in case that a canonical_alias is not set. In general this will save
screen real estate when a client uses the method to get a readable room
identifier to display to the user.
This new methods returns the most adequate identifier for a room:
1. If defined, the room's canonical alias.
2. Otherwise, the first alias.
3. As a last resort, the room identifier is returned.
Instead of adding more and more possible conditions on which the while-loop
inside client:sync() could stop, support passing a callback function which is
used to determine when to stop the loop.
The old "so N iterations behaviour" can be achieved with something like:
function iterate_n_times(n)
return function ()
n = n - 1
return n == 0
end
end
client:sync(iterate_n_times(10))
If no function is passed, the client:sync() function loops forever.
This handles the fact that when using the /sync endpoint, events for already
joined rooms are also in the "join" dictionary in the response. The firing of
the "joined" event is moved to client:_make_room() and done only the first
time that the room creation is requested.
This also fixes bogus behavior: previosly, when a message was sent to a room
there would be multiople places where the "joined" event would be fired, and
message events pushed multile times onto the room object, which would call
the event handlers more than once for each message. Ugh.
This neatly allows to pass the room object passed to the "invited" event
directly to :join_room(). This way the user does not need to know that
rooms have a "room_id" attribute.
This allows hooking to both room join and room leave events at the client
level, which apart from being more orthogonal, may be more convenient
sometimes.
This removes the currently unused "limit" parameter from
client:login_with_password() and client:register_with_password(), and adds a
new "no_sync" parameter. When the flag is set, the call to client:_sync() is
skipped. This can be useful for small scripts which do not need to do a sync
after login, yet they would rather user the higher level "matrix.client"
instead of the low level "matrix.api". For example, a simple script to send
a message to an already-known room given its ID could skip the sync in order
to be faster, without needing to revert to using "matrix.api".