Commit Graph

15 Commits

Author SHA1 Message Date
Adrian Perez de Castro
cadda45130 Handle "join" events properly
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.
2016-07-05 01:03:23 +03:00
Adrian Perez de Castro
bad6e6ee16 Allow passing a room object to client:join_room()
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.
2016-07-05 01:01:34 +03:00
Adrian Perez de Castro
e51b67aef6 Fire "message" events for rooms which receive messages 2016-07-05 00:59:55 +03:00
Adrian Perez de Castro
f879cd68e6 Have matrix.client fire "left" events when leaving a room
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.
2016-07-05 00:58:33 +03:00
Adrian Perez de Castro
a50931c3f6 Use room.client instead of room._client
This hints that the "client" attribute can be used from user code.
And it can.
2016-07-05 00:57:12 +03:00
Adrian Perez de Castro
fabb5330d1 First pass at client:sync()
For the moment only the amount of iterations, or processing events foerever,
can be specified. The timeout is not yet configurable.
2016-07-04 03:19:16 +03:00
Adrian Perez de Castro
02b3d880a6 Log the identifier of the batch of events being requested 2016-07-04 03:18:43 +03:00
Adrian Perez de Castro
9cd4e13310 Use xpcall() instead of pcall() to obtain tracebacks
Printing a traceback is much more help when debugging event handling.
2016-07-04 03:17:25 +03:00
Adrian Perez de Castro
c1492cd39a Add missing string format parameter when loggign property changes 2016-07-04 03:16:46 +03:00
Adrian Perez de Castro
03c1091742 Allow skipping the automatic sync on login/registration
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".
2016-07-03 15:06:25 +03:00
Adrian Perez de Castro
bd811c859e Rename matrix.factory.* -> matrix.httpclient.*
The old name didn't really make much sense after all...
2016-07-01 05:10:22 +03:00
Adrian Perez de Castro
e128366f7f Use eventables in matrix.client, implement a chunk of functionality
Yeah, I know: commits should have been smaller and all that. Yadda-yadda.
2016-07-01 05:05:50 +03:00
Adrian Perez de Castro
a1cf21b839 Implement room:update_room_{topic,aliases,name} 2016-06-23 04:17:15 +03:00
Adrian Perez de Castro
56a57f2e89 Add __tostring metamethods to prototypes
This is nice to have, and aids with debugging and interactive usage.
2016-06-23 04:07:01 +03:00
Adrian Perez de Castro
cafb8724e3 Import rough implementation of matrix.client 2016-06-23 03:54:48 +03:00