| 1: | <?php
|
| 2: |
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: | class SocketNative extends \Sphp\tools\Control {
|
| 9: |
|
| 10: | private $url = '';
|
| 11: |
|
| 12: | public function setURL($param) {
|
| 13: | $this->url = $param;
|
| 14: | }
|
| 15: |
|
| 16: | public function onjsrender() {
|
| 17: | $this->unsetRender();
|
| 18: | $protocol = "ws";
|
| 19: |
|
| 20: | addHeaderJSFunction('js_event_' . $this->name . '_msg', 'function js_event_' . $this->name . '_msg(evtp){', '}');
|
| 21: | $this->addAsJSVar();
|
| 22: | if (\SphpBase::sphp_request()->server('HTTPS') == 1)
|
| 23: | $protocol = "wss";
|
| 24: | if ($this->url == '')
|
| 25: | $this->url = $protocol . '://' . SphpBase::sphp_request()->server('HTTP_HOST') . '/sphp.ws';
|
| 26: | addHeaderJSFunctionCode("ready", "socketnative", $this->setAsJSVar("new sphp_wsocket('$this->url',js_event_{$this->name}_msg)"));
|
| 27: | }
|
| 28: |
|
| 29: | }
|
| 30: | |