Skip to content

Latest commit

 

History

History
39 lines (33 loc) · 2.8 KB

protocol.md

File metadata and controls

39 lines (33 loc) · 2.8 KB

LPIO Protocol.

LPIO is designed for scalable stateless architecture.

Client

  1. There is just one transport - HTTP Long Polling.

  2. Client sends an XHR POST request with JSON encoded body and headers:

    Accept: application/json
    Content-Type: application/json;charset=UTF-8
    
  3. Message is a json defined by this schema

  4. If client sends a message of type other than "ack" - it expects to receive an "ack" message.

  5. Client always sends an "ack" message in response when it receives messages of type other than "ack".

  6. Client expects to get an "ack" message within a time span defined by ackTimeout. If it doesn't - message is considered undelivered.

  7. Client waits for a response, until it gets one - request remains open.

  8. Client aborts currently waiting request to send new messages.

  9. After a successfully finished request client creates another one with new messages.

  10. After a failed request client resends a request using a backoff logic (backoff options). A reference implementation is backoff.

  11. Client accumulates messages to reduce amount of requests (multiplexer options)

  12. Client issues a timeout error if no message has been received within time span defined by responseTimeout. Client will close current request and create a new one with backoff.

  13. Client is disconnected when backoff duration reached the max value.

  14. Client is connected when a request was successfull.

  15. Client can have a static client id. If server wants to define the client id dynamically - it needs to respond with a message of type "option".

Server

  1. Server listens for XHR POST requests with JSON encoded body.
  2. Server doesn't respond if it has no new messages.
  3. Server always sends an "ack" message in response to any message type other than "ack".
  4. Server sends a json encoded body defined by this schema
  5. Server accumulates messages to reduce amount of responses (multiplexer options)
  6. If request body doesn't contain client id, server should respond immediately with a message of type "option" to define the client id.
  7. Message is a json defined by this schema
  8. The knowledge about connected/disconnected users is not a part of LPIO server.
  9. There is no separate handshake requests, every request is signed.
  10. If client is unauthorized, server should respond with 403 http status code.