michaelKurowski / lokim2

An internet messenger that cares about privacy.
4 stars 0 forks source link

Standarized format for websocket message #168

Closed michaelKurowski closed 5 years ago

michaelKurowski commented 5 years ago

Is your feature request related to a problem? Please describe. We need a standarized format for wesbsocket communication.

Describe the solution you'd like

{
   action: typeName, // Action type, i.e. message
   payload: payload, // Payload specific to certain action
   date: UNIX timestamp // timestamp of point in time where server registered the event
}

Action IDs and Payload formats for currently implemented responses: USER_JOINED

{
   username: username,
   roomId: roomId
}

USER_LEFT

{
   username: username,
   roomId: roomId
}

MESSAGE

{
   author: username,
   text: text,
   roomId: room id
}

LIST_MEMBERS

{
   usernames: [username1, username2 ...],
   roomId: room id
}

USERS_FOUND

{
   usernames: [username1, username2 ...]
}

It could be a class or builder function

Describe alternatives you've considered N/A

User story N/A

Additional context N/A