Polyjuice Client v0.4.4 Polyjuice.Client.Handler protocol View Source

Protocol for client event handlers.

Link to this section Summary

Functions

Handle an event from the client.

Link to this section Types

Link to this section Functions

Link to this function

handle(handler, event_type, args \\ nil)

View Source
handle(handler :: t(), event_type :: atom(), args :: tuple() | nil) :: any()

Handle an event from the client.

Events (in the form type, args) may include:

  • :logged_in, {user_id, device_id, login_info}: the user was logged in.
  • :logged_out, {soft_logout}: the user was logged out.
  • :sync_connected, nil: the sync process has connected to the homeserver
  • :sync_disconnected, nil: the sync process has been disconnected from the homeserver
  • :initial_sync_completed, nil: the first sync after login has completed
  • :limited, {room_id, prev_batch} a room's timeline has been limited. Previous messages can be fetched using the prev_batch
  • :message, {room_id, event}: a message event has been received
  • :state, {room_id, event}: a state event has been received
  • :invite, {room_id, inviter, invite_state}: the user was invited to a room
  • :left, {room_id}: the user left a room

If a PID is used as a handler, the process will be sent a message of the form {:polyjuice_client, type}, if args is nil, or {:polyjuice_client, type, args} otherwise.

If a function is used as a handler, it must have arity 2, and will be given type and args as its arguments.