1
0

BxDolSockets.js 844 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * Copyright (c) UNA, Inc - https://una.io
  3. * MIT License - https://opensource.org/licenses/MIT
  4. *
  5. * @defgroup UnaCore UNA Core
  6. * @{
  7. */
  8. function BxDolSockets(oOptions)
  9. {
  10. this._sKey = oOptions.sKey;
  11. this._sHost = oOptions.sHost;
  12. this._sPort = oOptions.sPort;
  13. this._sObject = oOptions.sObject === undefined ? 'oBxDolSockets' : oOptions.sObject;
  14. this._oPusher = new Pusher(this._sKey, {
  15. wsHost: oOptions.sHost,
  16. wsPort: oOptions.sPort,
  17. forceTLS: false,
  18. enabledTransports: ['ws', 'wss'],
  19. cluster:''
  20. });
  21. }
  22. BxDolSockets.prototype.subscribe = function(module, content_id, event, cb)
  23. {
  24. if(!this._oPusher)
  25. return;
  26. var channel = this._oPusher.subscribe(module + '_' + content_id);
  27. channel.bind(event, function(data) {
  28. cb(data)
  29. });
  30. }
  31. /** @} */