-
Notifications
You must be signed in to change notification settings - Fork 1k
Node.js
james2doyle edited this page Sep 12, 2014
·
2 revisions
The websocketd works with line-breaks. String.trim()
will fix that for you, but don't forget to end with a line-break when sending data.
script.js
// Start listening
process.stdin.resume()
process.stdin.setEncoding('utf8')
// Receive data from WebSocket - STDIN
process.stdin.on( 'data', function( data ) {
// Send data to WebSocket client - STDOUT
process.stdout.write( JSON.stringify({ text: data.trim() }) +'\n' )
})
websocketd nodejs script.js
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