You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.4 KiB
ReStructuredText
91 lines
3.4 KiB
ReStructuredText
10 years ago
|
Events
|
||
|
======
|
||
|
|
||
10 years ago
|
All communication in Matrix is expressed in the form of data objects called
|
||
10 years ago
|
Events. These are the fundamental building blocks common to the client-server,
|
||
|
server-server and application-service APIs, and are described below.
|
||
10 years ago
|
|
||
10 years ago
|
{{common_event_fields}}
|
||
10 years ago
|
|
||
10 years ago
|
{{common_room_event_fields}}
|
||
10 years ago
|
|
||
10 years ago
|
{{common_state_event_fields}}
|
||
10 years ago
|
|
||
|
|
||
|
Room Events
|
||
|
-----------
|
||
|
.. NOTE::
|
||
|
This section is a work in progress.
|
||
|
|
||
|
This specification outlines several standard event types, all of which are
|
||
|
prefixed with ``m.``
|
||
|
|
||
10 years ago
|
{{room_events}}
|
||
10 years ago
|
|
||
|
m.room.message msgtypes
|
||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
|
||
|
.. TODO-spec
|
||
|
How a client should handle unknown message types.
|
||
|
|
||
10 years ago
|
|
||
10 years ago
|
Each `m.room.message`_ MUST have a ``msgtype`` key which identifies the type
|
||
10 years ago
|
of message being sent. Each type has their own required and optional keys, as
|
||
10 years ago
|
outlined below.
|
||
10 years ago
|
|
||
10 years ago
|
{{msgtype_events}}
|
||
10 years ago
|
|
||
10 years ago
|
Presence Events
|
||
|
~~~~~~~~~~~~~~~
|
||
10 years ago
|
|
||
10 years ago
|
{{presence_events}}
|
||
|
|
||
|
Each user has the concept of presence information. This encodes the
|
||
|
"availability" of that user, suitable for display on other user's clients.
|
||
|
This is transmitted as an ``m.presence`` event and is one of the few events
|
||
|
which are sent *outside the context of a room*. The basic piece of presence
|
||
|
information is represented by the ``presence`` key, which is an enum of one
|
||
|
of the following:
|
||
10 years ago
|
|
||
|
- ``online`` : The default state when the user is connected to an event
|
||
|
stream.
|
||
|
- ``unavailable`` : The user is not reachable at this time.
|
||
|
- ``offline`` : The user is not connected to an event stream.
|
||
|
- ``free_for_chat`` : The user is generally willing to receive messages
|
||
|
moreso than default.
|
||
|
- ``hidden`` : Behaves as offline, but allows the user to see the client
|
||
|
state anyway and generally interact with client features. (Not yet
|
||
|
implemented in synapse).
|
||
|
|
||
10 years ago
|
In addition, the server maintains a timestamp of the last time it saw a
|
||
|
pro-active event from the user; either sending a message to a room, or
|
||
|
changing presence state from a lower to a higher level of availability
|
||
|
(thus: changing state from ``unavailable`` to ``online`` counts as a
|
||
|
proactive event, whereas in the other direction it will not). This timestamp
|
||
|
is presented via a key called ``last_active_ago``, which gives the relative
|
||
|
number of milliseconds since the message is generated/emitted that the user
|
||
|
was last seen active.
|
||
10 years ago
|
|
||
10 years ago
|
|
||
|
Events on Change of Profile Information
|
||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
Because the profile displayname and avatar information are likely to be used in
|
||
|
many places of a client's display, changes to these fields cause an automatic
|
||
|
propagation event to occur, informing likely-interested parties of the new
|
||
|
values. This change is conveyed using two separate mechanisms:
|
||
|
|
||
|
- a ``m.room.member`` event is sent to every room the user is a member of,
|
||
|
to update the ``displayname`` and ``avatar_url``.
|
||
10 years ago
|
- a ``m.presence`` presence status update is sent, again containing the new values of the
|
||
10 years ago
|
``displayname`` and ``avatar_url`` keys, in addition to the required
|
||
|
``presence`` key containing the current presence state of the user.
|
||
|
|
||
|
Both of these should be done automatically by the home server when a user
|
||
|
successfully changes their displayname or avatar URL fields.
|
||
|
|
||
|
Additionally, when home servers emit room membership events for their own
|
||
|
users, they should include the displayname and avatar URL fields in these
|
||
|
events so that clients already have these details to hand, and do not have to
|
||
|
perform extra roundtrips to query it.
|
||
|
|