BxDolSockets.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaCore UNA Core
  7. * @{
  8. */
  9. class BxDolSockets extends BxDolFactory implements iBxDolSingleton
  10. {
  11. protected $_sHost;
  12. protected $_sPort;
  13. protected $_sScheme;
  14. protected $_sIsEnabled;
  15. protected function __construct()
  16. {
  17. parent::__construct();
  18. $this->_sIsEnabled = false;
  19. if(getParam('sys_sockets_type') == 'sys_sockets_disabled')
  20. return;
  21. $sUrl = trim(getParam('sys_sockets_url'));
  22. if(!$sUrl)
  23. return;
  24. $a = parse_url($sUrl);
  25. $this->_sHost = $a['host'] ?? '';
  26. $this->_sPort = $a['port'] ?? '';
  27. $this->_sScheme = $a['scheme'] ?? '';
  28. $this->_sIsEnabled = true;
  29. }
  30. static public function getInstance()
  31. {
  32. if(!isset($GLOBALS['bxDolClasses']['BxDolSockets'])){
  33. $GLOBALS['bxDolClasses']['BxDolSockets'] = new BxDolSockets();
  34. if (getParam('sys_sockets_type') == 'sys_sockets_soketi')
  35. $GLOBALS['bxDolClasses']['BxDolSockets'] = new BxDolSocketsSoketi();
  36. }
  37. return $GLOBALS['bxDolClasses']['BxDolSockets'];
  38. }
  39. public function isEnabled()
  40. {
  41. return $this->_sIsEnabled;
  42. }
  43. public function sendEvent($sSocket, $iContentId, $sEvent, $sMessage)
  44. {
  45. return;
  46. }
  47. public function getJsCode()
  48. {
  49. return '';
  50. }
  51. public function writeLog($sString)
  52. {
  53. bx_log('sys_sockets', $sString);
  54. }
  55. }
  56. /** @} */