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.

43 lines
1.1 KiB

4 years ago
  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. return Base.isWebSocket(request);
  29. },
  30. validateOptions: function(options, validKeys) {
  31. Base.validateOptions(options, validKeys);
  32. }
  33. };
  34. module.exports = Driver;