LPIO is designed for scalable stateless architecture.
-
There is just one transport - HTTP Long Polling.
-
Client sends an XHR POST request with JSON encoded body and headers:
Accept: application/json Content-Type: application/json;charset=UTF-8
-
Message is a json defined by this schema
-
If client sends a message of type other than "ack" - it expects to receive an "ack" message.
-
Client always sends an "ack" message in response when it receives messages of type other than "ack".
-
Client expects to get an "ack" message within a time span defined by
ackTimeout
. If it doesn't - message is considered undelivered. -
Client waits for a response, until it gets one - request remains open.
-
Client aborts currently waiting request to send new messages.
-
After a successfully finished request client creates another one with new messages.
-
After a failed request client resends a request using a backoff logic (backoff options). A reference implementation is backoff.
-
Client accumulates messages to reduce amount of requests (multiplexer options)
-
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. -
Client is disconnected when backoff duration reached the
max
value. -
Client is connected when a request was successfull.
-
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 listens for XHR POST requests with JSON encoded body.
- Server doesn't respond if it has no new messages.
- Server always sends an "ack" message in response to any message type other than "ack".
- Server sends a json encoded body defined by this schema
- Server accumulates messages to reduce amount of responses (multiplexer options)
- If request body doesn't contain
client
id, server should respond immediately with a message of type "option" to define the client id. - Message is a json defined by this schema
- The knowledge about connected/disconnected users is not a part of LPIO server.
- There is no separate handshake requests, every request is signed.
- If client is unauthorized, server should respond with
403
http status code.