| Crates.io | wsa |
| lib.rs | wsa |
| version | 1.0.4 |
| created_at | 2025-05-19 15:47:43.027707+00 |
| updated_at | 2025-05-20 05:47:15.089677+00 |
| description | WebSocket-based API protocol. |
| homepage | https://github.com/ipel-dev/wsa |
| repository | https://github.com/ipel-dev/wsa |
| max_upload_size | |
| id | 1679908 |
| size | 10,165 |
This document defines the specification for a WebSocket-based API protocol. It applies to production environments, using compressed formats.
"server" or a specific client_idfrom is server, it's the only global serverclient_idCan be:
"server": for messages directed to the server"client_id": when directed from a client to another client (via server proxy)"client": broadcast message to all clients (only allowed from server)client can be the target (to) if the message originates from the server, or is routed via the server from another clientto: "client", but it must be relayed through the server, which will handle authentication and authorization.Only three values are allowed:
"request""response""event"Message id is chosen by the sender
It should be the ISO8601 timestamp at the moment of sending, e.g.:
"2025-05-14T11:27:31.536370717+08:00"
This feature may be cancelled in the next version. At that time, it will be changed to a string of [a-z0-9]{5}, msg_id.
For response type messages:
id must match the original request or event message's IDresponse messages must not use a new unique ID{
"from": "",
"to": "",
"type": "request",
"id": "",
"payload": {
"method": "auth@v1/login",
"params": {}
}
}
method: target service and versioned endpoint (e.g. auth@v1/login)params: arguments passed to backend service function{
"from": "",
"to": "",
"type": "response",
"id": "",
"payload": {
"result": "success",
"receipt": "optional_id_or_null"
}
}
{
"from": "",
"to": "",
"type": "response",
"id": "",
"payload": {
"result": "fail",
"code": "PERMISSION_DENIED"
}
}
{
"from": "",
"to": "",
"type": "event",
"id": "",
"payload": {
"method": "chat@v1/message",
"params": {}
}
}
{
"f": "s",
"t": "",
"y": "g",
"i": "abc12",
"P": {}
}
{
"p": {
"m": "auth@v1/login",
"p": ["arg1", "arg2"]
}
}
{
"p": {
"r": "s",
"c": "resource_id"
}
}
{
"p": {
"r": "f",
"c": "PERMISSION_DENIED"
}
}
This format is optimized for bandwidth-sensitive environments by shortening keys and values. It is strongly recommended to use the verbose version during development and the compact version in production deployments.