This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "zuul-214", | |
"version": "1.0.0", | |
"description": "", | |
"main": "test.js", | |
"scripts": { | |
"zuul": "zuul" | |
}, | |
"author": "", | |
"license": "ISC", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var Socket = require('primus').createSocket({ transformer: 'faye' }) | |
, one = new Socket('http://localhost:3001') | |
, two; | |
one.on('data', function (data) { | |
console.log('"one" received message: '+ data); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var container = document.getElementById('container'); | |
var socket = new eio('http://192.168.0.197:3000/', { | |
transports: [ 'websocket' ] | |
}); | |
socket.on('data', function (data) { | |
var p = document.createElement('p'); | |
p.textContent = data; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Client = require('engine.io-client') | |
, Engine = require('engine.io') | |
, http = require('http'); | |
var server = http.createServer() | |
, engine = new Engine(); | |
engine.on('connection', function connection(socket) { | |
var onDataRequest = socket.transport.onDataRequest; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var ws = new WebSocket('ws://localhost:3000'); | |
ws.onopen = function open() { | |
console.log('open'); | |
ws.send('Hello, world!'); | |
}; | |
ws.onmessage = function message(event) { | |
console.log(event.data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var Faye = require('faye-websocket'); | |
var ws = new Faye.Client('ws://localhost:3000/'); | |
ws.on('open', function open() { | |
console.log('open'); | |
ws.send('Hello, world!'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "gh-321", | |
"version": "1.0.0", | |
"description": "", | |
"main": "server.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "MIT", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var ws = new WebSocket('ws://localhost:3000'); | |
ws.onopen = function () { | |
ws.send('shutdown'); | |
}; | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var server = require('http').createServer(); | |
var net = require('net'); | |
function write(port, host) { | |
this.write([ | |
'GET ws://' + host + ':' + port + '/ HTTP/1.1', | |
'Host: ' + host, | |
'Upgrade: websocket', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ws = require('ws') | |
, http = require('http'); | |
var server = http.createServer(); | |
var wss = new ws.Server({ noServer: true }); | |
server.on('upgrade', function (req, socket, head) { | |
setTimeout(function () { | |
wss.handleUpgrade(req, socket, head, function (socket) { | |
socket.on('message', function (message) { |