mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-11-14 07:06:17 +00:00
33 lines
802 B
JavaScript
33 lines
802 B
JavaScript
|
var WebSocket = require('..').Client,
|
||
|
deflate = require('permessage-deflate'),
|
||
|
fs = require('fs');
|
||
|
|
||
|
var url = process.argv[2],
|
||
|
proxy = process.argv[3],
|
||
|
ca = fs.readFileSync(__dirname + '/../spec/server.crt'),
|
||
|
tls = {ca: ca};
|
||
|
|
||
|
var ws = new WebSocket(url, [], {
|
||
|
proxy: {origin: proxy, headers: {'User-Agent': 'Echo'}, tls: tls},
|
||
|
tls: tls,
|
||
|
headers: {Origin: 'http://faye.jcoglan.com'},
|
||
|
extensions: [deflate]
|
||
|
});
|
||
|
|
||
|
ws.onopen = function() {
|
||
|
console.log('[open]', ws.headers);
|
||
|
ws.send('mic check');
|
||
|
};
|
||
|
|
||
|
ws.onclose = function(close) {
|
||
|
console.log('[close]', close.code, close.reason);
|
||
|
};
|
||
|
|
||
|
ws.onerror = function(error) {
|
||
|
console.log('[error]', error.message);
|
||
|
};
|
||
|
|
||
|
ws.onmessage = function(message) {
|
||
|
console.log('[message]', message.data);
|
||
|
};
|