This file contains the guidelines to communicate with the server. Proper response, when possible, is sent by the server.
- Communicating with the Server
- The first message sent must be a login/registration request to the server when making a socket connection.
- Failure to do so will result in error.
- It should be a valid JSON message.
- A new request should be made to generate a new OTP.
When registering, NONE OF THE KEYS CAN BE NULL.
{
"type": "registration",
"details": {
"email": "[email protected]",
"password": "md5-hashed-password",
"username": "xyz"
}
}
{
"type": "verify",
"otp": "1234"
}
{
"event": "sent",
"type": "otp",
"message": "OTP sent to [email protected]"
}
{
"event": "success",
"type": "verify"
}
{
"event": "failed",
"type": "otp or registration or verify",
"message": "Reason why the user was not registered"
}
NOTE: After successful registration, the user should be taken back to the login screen. The user will not be logged in after registration.
- The first message sent must be a login/registration request to the server when making a socket connection.
- Failure to do so will result in error.
- It should be a valid JSON message.
Either the "username" or the "email" key can be null, both cannot be null.
{
"type": "login",
"details": {
"username": "xyz",
"email": "[email protected]",
"password": "md5-hashed-password"
}
}
- The response data will contain the username and email address of the user.
- The response data will also contain a list of all the users the user has previously contacted or has been contacted by.
{
"event": "success",
"type": "login",
"details": {
"username": "xyz",
"email": "[email protected]",
"friends": [
{
"email": "[email protected]",
"username": "xyz"
},
{
"email": "[email protected]",
"username": "def"
}
]
}
}
{
"event": "failed",
"type": "login",
"message": "Reason why user was not logged in"
}
- The server won't end all I/O connections on logout, the connection should terminate ideally when the client application is not running.
{
"type": "logout"
}
{
"event": "success",
"type": "logout"
}
- This is the basic message conversation format.
- The message layout of all messages are similar with some minor but important changes.
- Used to communicate with all the users in the server, these messages are to be sent when the user wants to send the message to everyone.
{
"event": "global",
"type": "message",
"details": {
"message": "Hello World",
"time": 1234567890
}
}
{
"event": "global",
"type": "message",
"details": {
"message": "Hello World",
"media": "https://url-to-firestore/",
"time": 1234567890
}
}
{
"event": "global",
"type": "message",
"details": {
"message": "Hello World",
"from": "[email protected]",
"time": 1234567890
}
}
{
"event": "global",
"type": "message",
"details": {
"message": "Hello World",
"media": "https://url-to-firstore",
"from": "[email protected]",
"time": 1234567890
}
}
- Also known as direct messages, these messages are to be sent when the user wants to send the message to only one specific user.
{
"event": "personal",
"type": "message",
"details": {
"to": "[email protected]",
"message": "Hello World",
"time": 1234567890
}
}
{
"event": "personal",
"type": "message",
"details": {
"to": "[email protected]",
"message": "Hello World",
"media": "https://url-to-firestore/",
"time": 1234567890
}
}
{
"event": "personal",
"type": "message",
"details": {
"id": "some-id",
"message": "Hello World",
"from": "[email protected]",
"time": 1234567890
}
}
{
"event": "personal",
"type": "message",
"details": {
"id": "some-id",
"message": "Hello World",
"media": "https://url-to-firestore",
"from": "[email protected]",
"time": 1234567890
}
}
- This is the standard response from the server when a personal message is sent.
- No response is sent for Global Messages.
{
"event": "sent",
"type": "message",
"id": "id-for-the-message"
}
- This will return a list of all the users registered to the server
{
"type": "users"
}
{
"event": "success",
"type": "users",
"details": [
{
"username": "xyz",
"email": "[email protected]"
},
"List-of-objects"
]
}
- When placing a call, the current user must send the email address of the person he wants to call in the following format.
{
"type": "voice",
"event": "call",
"details": {
"email": "[email protected]"
}
}
- The server will try to communicate with the recipient of the call by sending the following message.
{
"type": "voice",
"event": "request",
"details": {
"email": "[email protected]"
}
}
- For accepting the call, the recipient of the call should send the following response
{
"type": "voice",
"event": "accept",
"details": {
"email": "[email protected]"
}
}
- For accepting the call, the recipient of the call should send the following response
{
"type": "voice",
"event": "reject",
"details": {
"email": "[email protected]"
}
}
- The server will wait 30 seconds for a response from the recipient of the call.
- If in that time, no response is received, the server will send the following response to the caller:
{
"type": "voice",
"event": "time",
"details": {
"email": "[email protected]"
}
}
- And the following response to the receiver:
{
"type": "voice",
"event": "time",
"details": {
"email": "[email protected]"
}
}
- When the receiver accepts the call, 2 responses are sent from the server
- To do the one who makes the call
- To the one who receives the call
- The message contains the details of the IP Address and port over to which the UDP packets should be sent.
{
"type": "voice",
"event": "accept",
"details": {
"ip": "x.x.x.x",
"port": "0000"
}
}
- If the receiver rejects the call the following response is sent to the caller.
{
"type": "voice",
"event": "reject",
"details": {
"email": "[email protected]"
}
}
- If the receiver is not available to take your call, the server will send the following response:
{
"type": "voice",
"event": "offline",
"details": {
"email": "[email protected]"
}
}
- Whenever any error occurs, a response in this format will be sent by the server to the person requesting the service.
{
"event": "invalid or failed",
"type": "type-of-request-made",
"message": "A message regarding the event."
}