a zip code crypto-currency system good for red ONLY

driver.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 'use strict';
  2. // Protocol references:
  3. //
  4. // * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75
  5. // * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76
  6. // * http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17
  7. var Base = require('./driver/base'),
  8. Client = require('./driver/client'),
  9. Server = require('./driver/server');
  10. var Driver = {
  11. client: function(url, options) {
  12. options = options || {};
  13. if (options.masking === undefined) options.masking = true;
  14. return new Client(url, options);
  15. },
  16. server: function(options) {
  17. options = options || {};
  18. if (options.requireMasking === undefined) options.requireMasking = true;
  19. return new Server(options);
  20. },
  21. http: function() {
  22. return Server.http.apply(Server, arguments);
  23. },
  24. isSecureRequest: function(request) {
  25. return Server.isSecureRequest(request);
  26. },
  27. isWebSocket: function(request) {
  28. if (request.method !== 'GET') return false;
  29. var connection = request.headers.connection || '',
  30. upgrade = request.headers.upgrade || '';
  31. return request.method === 'GET' &&
  32. connection.toLowerCase().split(/ *, */).indexOf('upgrade') >= 0 &&
  33. upgrade.toLowerCase() === 'websocket';
  34. },
  35. validateOptions: function(options, validKeys) {
  36. Base.validateOptions(options, validKeys);
  37. }
  38. };
  39. module.exports = Driver;