A simple WebSocket implementation, written only in Shell Script.
$ ./make.sh
-
Load the built script.
. ./websocket.sh
-
Creating a Pipe to handle the stream.
HANDLE="$(ws_create)"
-
Prepare functions to handle events.
on_message() { MESSAGE="$1" echo "on_message: $MESSAGE" } on_connect() { echo "on_connect" # TODO: Start sending something... }
-
Connect to your server.
ws_connect "hostname.local" "80" "/connect" "on_message" "on_connect" # ws_connect [hostname] [port] [path] [on_message] [on_connect]
-
Send something.
ws_write "Hey!"