UNPKG

e-lado

Version:

[![CircleCI](https://circleci.com/gh/sharetribe/sharetribe/tree/master.svg?style=svg)](https://circleci.com/gh/sharetribe/sharetribe/tree/master) [![Dependency Status](https://gemnasium.com/sharetribe/sharetribe.png)](https://gemnasium.com/sharetribe/shar

24 lines (19 loc) 675 B
var WebSocket = require('../lib/faye/websocket'), port = process.argv[2] || 7000, secure = process.argv[3] === 'ssl', scheme = secure ? 'wss' : 'ws', url = scheme + '://localhost:' + port + '/', headers = {Origin: 'http://faye.jcoglan.com'}, ws = new WebSocket.Client(url, null, {headers: headers}); console.log('Connecting to ' + ws.url); ws.onopen = function(event) { console.log('open'); ws.send('Hello, WebSocket!'); }; ws.onmessage = function(event) { console.log('message', event.data); // ws.close(1002, 'Going away'); }; ws.onclose = function(event) { console.log('close', event.code, event.reason); };