Realtime
#
RealtimeAt Misakey, realtime is managed through websockets or polling. We aim at manage our whole realtime through websockets.
#
WebsocketsThe websockets protocol uses the same handshake as http requests.
Servers can differenciate them thanks to the Connection: Upgrade
header.
Our server send regular (every 60 seconds) Pings
to check the connection state.
For now, there is no action triggered by a lack of a Pong
response.
Authentication is made through an access token. As the javascript lib does not allow custom headers, we need to pass the access token through query parameters. We will improve this authentication process in the future.
Each user can subscribe to wss://api.misakey.com/box-users/:id/ws
to have realtime messages.
#
Message FormatsAll websockets messages are under the following format:
event.new
server-to-client#
The most important use of realtime at Misakey is to manage new box events. Their type is event.new
.
They are server to client messages.
Here are the events that can be received:
state.access_mode
#
msg.text
#
msg.file
#
msg.delete
#
msg.edit
#
member.join
#
member.leave
#
member.kick
#
#
Other server-to-clientbox.delete
#
This message notifies a box deletion.
box.auto_invite
#
This message notifies an invitation.
box.settings
#
This message notifies a box settings update.
file.saved
#
This message notifies a change in the saved status of a file for a given user.
#
Client-to-serverServer accepts only events of the type ack
:
ack
#
These messages are sent when a user want to acknowledge the events count on a box.
This set the events count to 0 for the user on the box.