You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
802 B

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