1: <?php
2:
3: /**
4: * Description of SocketNative
5: * Socket work with native app to process as outsider from web server environment.
6: * @author SARTAJ
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: //event handler
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: