-
Notifications
You must be signed in to change notification settings - Fork 1k
Ten second tutorial
joewalnes edited this page Mar 22, 2013
·
12 revisions
This is a really quick run through of getting a WebSocket application up and running with websocketd
. Quick, only eight seconds left!
We'll use bash. But you can use anything.
count.sh:
#!/bin/bash
# Count from 1 to 10, pausing for a second between each iteration.
for COUNT in $(seq 1 10); do
echo $COUNT
sleep 1
done
Make it executable:
$ chmod +x ./count.sh
$ websocketd --port=8080 ./count.sh
In a web-page:
var ws = new WebSocket('ws://localhost:8080/');
ws.onmessage = function(event) {
console.log('Count is: ' + event.data);
};
Ok, got it?
Wanna learn more. Read the slightly more verbose ten MINUTE tutorial instead.
The websocketd user guide is a publicly editable wiki. Please contribute!
Getting Started
Reference
Language specific
Advanced: Internals
Spanish Websocket Wiki
Primeros pasos
Referencia
Lenguajes
Avanzado