Go to file
Emery Hemingway 11af5d9422 Syndicate API update 2023-10-21 18:38:10 +01:00
src Syndicate API update 2023-10-21 18:38:10 +01:00
.envrc Initial commit 2023-09-13 16:20:27 +02:00
.gitignore Add lockfile 2023-10-19 18:09:04 +01:00
README.md Initial commit 2023-09-13 16:20:27 +02:00
Tupfile Add lockfile 2023-10-19 18:09:04 +01:00
Tuprules.tup Add lockfile 2023-10-19 18:09:04 +01:00
lock.json Syndicate API update 2023-10-21 18:38:10 +01:00
shell.nix Initial commit 2023-09-13 16:20:27 +02:00
websocket_actor.nimble Syndicate API update 2023-10-21 18:38:10 +01:00

README.md

websocket_actor

A syndicated actor for communicating JSON to websocket servers.

The actor observes {dataspace: #!any url: string } assertions and connects to a websocket endpoint. During the lifetime of the connection a <connected $URL> assertion is made. Messages recieved from the server are sent to the dataspace wrapped in <recv …> records and messages observed as <send …> are sent to the server.

Unfortunately this utility is only as useful and reasonable as the websocket server it is connected to.

Example:

Syndicate server configuration:

<require-service <daemon websocket_actor>>
<daemon websocket_actor {
  argv: ["/bin/websocket_actor"]
  protocol: application/syndicate
  env: { BUILD_SUM: $sum }
}>

let ?exported-dataspace = dataspace
<service-object <daemon websocket_actor> ?cap> [
  $cap { dataspace: $exported-dataspace url: "ws://127.0.0.1:5225/" }
]

<bind <ref { oid: "syndicate" key: #x"" }> $exported-dataspace #f>

Shell

# Use the "syndump" utility to log '<recv …>' records from the background.
syndump '<recv ?>' &

# Use the "msg" utilite to send '<send …>' records.
# The message command wraps its arguments in a record with a label set to argv[0].
cp $(which msg) send
send '{ type: "command" body: { type: "body" text: "fuck off webdevs"} }'