dispatch
Version, currently 1.5.210 versions
github.com/PlaceOS/dispatch
Distribution service for handling device initiatated connections.
Installation
# Add this to your shard.yml
dependencies:
dispatch:
github: PlaceOS/dispatch
version: ~> 1.5.2Then run:
shards installshard.yml
- Crystal
~> 1.0- Target
dispatchfrom src/app.cr
Dependencies
Runtime Dependencies
- bindata*github: spider-gazelle/bindata
- log_helper*github: spider-gazelle/log_helper
- secrets-env*github: place-labs/secrets-env
- placeos-models~> 8.1github: placeos/models
- action-controller~> 5.3github: spider-gazelle/action-controller
- placeos-log-backend>= 0.11.0github: place-labs/log-backend
Development Dependencies
- ameba~> 0.14github: crystal-ameba/amebadev
README
Server Dispatch
This allows engine drivers to register new servers for devices that might connect to engine vs engine connecting to devices.
- Drivers can indicate a port they want open and the IP addresses they'll accept data from.
- The details of the clients and data is then streamed to the drivers.
- Servers are only opened if there is a driver listening and ports are closed otherwise.
ENV Vars
PLACE_SERVER_SECRET= shared bearer token for driver authSG_ENV= set toproductionfor production log levels
Usage
There are two websocket endpoints one for TCP and one for UDP
/api/dispatch/v1/tcp_dispatch/api/dispatch/v1/udp_dispatch
The query string should include the
bearer_tokenused to authenticate the requestportthe server should run onaccepta comma delimited list of client IP addresses that are expected to connect to the server
WS /api/dispatch/v1/tcp_dispatch?bearer_token=testing&port=6001&accept=127.0.0.1
The websocket only communicates over BINARY frames and has the following message types:
- OPENED ==
0dispatcher => driver - a TCP client connected to the server - CLOSED ==
1dispatcher => driver - a TCP client disconnected - RECEIVED ==
2dispatcher => driver - data was received from a UDP or TCP client - WRITE ==
3driver => dispatcher - request some data be written to a UDP or TCP client - CLOSE ==
4driver => dispatcher - request a TCP client be disconnected
The message structure sent down the websocket looks like:
uint8 message_type (OPENED, CLOSED etc)
string ip_address (remote IP, with null character termination)
uint64 id_or_port (client id for TCP, remote port for UDP)
uint32 data_size (number of bytes of data included)
bytes data (any data associated with the message, RECEIVED and WRITE messages only)
Statistics
Statistics are available via a GET request
GET /api/server?bearer_token=testing
{
# Engine drivers requesting a UDP server be open
"udp_listeners": {"162": 8},
# Engine drivers requesting a TCP server be open
"tcp_listeners": {"6001": 1},
# Remote clients connected to the live servers
"tcp_clients": {"6001": 1}
}
Deployment
When deployed in the cloud, one can configure K8s load balancer to forward data coming in on required ports to Dispatch.
Contributing
See CONTRIBUTING.md.
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
1.5.2- Tagged
- Mar 15, 2023
- Commit
917312bce7f8- Crystal
~> 1.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/PlaceOS/dispatch
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 10