1
|
var WebSocket = require('..').Client,
|
2
|
deflate = require('permessage-deflate'),
|
3
|
fs = require('fs');
|
4
|
|
5
|
var url = process.argv[2],
|
6
|
proxy = process.argv[3],
|
7
|
ca = fs.readFileSync(__dirname + '/../spec/server.crt'),
|
8
|
tls = {ca: ca};
|
9
|
|
10
|
var ws = new WebSocket(url, [], {
|
11
|
proxy: {origin: proxy, headers: {'User-Agent': 'Echo'}, tls: tls},
|
12
|
tls: tls,
|
13
|
headers: {Origin: 'http://faye.jcoglan.com'},
|
14
|
extensions: [deflate]
|
15
|
});
|
16
|
|
17
|
ws.onopen = function() {
|
18
|
console.log('[open]', ws.headers);
|
19
|
ws.send('mic check');
|
20
|
};
|
21
|
|
22
|
ws.onclose = function(close) {
|
23
|
console.log('[close]', close.code, close.reason);
|
24
|
};
|
25
|
|
26
|
ws.onerror = function(error) {
|
27
|
console.log('[error]', error.message);
|
28
|
};
|
29
|
|
30
|
ws.onmessage = function(message) {
|
31
|
console.log('[message]', message.data);
|
32
|
};
|