Skip to content

Commit

Permalink
Changed swoole server to public property for #14 and #18
Browse files Browse the repository at this point in the history
  • Loading branch information
andot committed Apr 8, 2016
1 parent 9e00a24 commit 2508222
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions src/Hprose/Swoole/Http/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
* *
* hprose swoole http server library for php 5.3+ *
* *
* LastModified: Jun 6, 2015 *
* LastModified: Apr 8, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/

namespace Hprose\Swoole\Http {
class Server extends Service {
private $http;
public $server;
public function __construct($host, $port, $mode = SWOOLE_PROCESS) {
parent::__construct();
$this->http = new \swoole_http_server($host, $port, $mode);
$this->server = new \swoole_http_server($host, $port, $mode);
}
public function set($setting) {
$this->http->set($setting);
$this->server->set($setting);
}
public function addListener($host, $port) {
$this->http->addListener($host, $port);
$this->server->addListener($host, $port);
}
public function start() {
$this->http->on('request', array($this, 'handle'));
$this->http->start();
$this->server->on('request', array($this, 'handle'));
$this->server->start();
}
}
}
4 changes: 2 additions & 2 deletions src/Hprose/Swoole/Http/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* *
* hprose swoole http service library for php 5.3+ *
* *
* LastModified: Jun 28, 2015 *
* LastModified: Apr 8, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
Expand Down Expand Up @@ -110,7 +110,7 @@ public function handle($request, $response) {
$data = $request->rawContent();

$context = new \stdClass();
$context->server = $this;
$context->server = $this->server;
$context->request = $request;
$context->response = $response;
$context->userdata = new \stdClass();
Expand Down
4 changes: 2 additions & 2 deletions src/Hprose/Swoole/Socket/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* *
* hprose swoole socket server library for php 5.3+ *
* *
* LastModified: Jun 7, 2015 *
* LastModified: Apr 8, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/

namespace Hprose\Swoole\Socket {
class Server extends Service {
private $server;
public $server;
private function parseUrl($url) {
$result = new \stdClass();
$p = parse_url($url);
Expand Down
16 changes: 8 additions & 8 deletions src/Hprose/Swoole/WebSocket/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@
* *
* hprose swoole websocket server library for php 5.3+ *
* *
* LastModified: Jun 6, 2015 *
* LastModified: Apr 8, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/

namespace Hprose\Swoole\WebSocket {
class Server extends Service {
private $ws;
public $server;
public function __construct($host, $port, $mode = SWOOLE_PROCESS) {
parent::__construct();
$this->ws = new \swoole_websocket_server($host, $port, $mode);
$this->server = new \swoole_websocket_server($host, $port, $mode);
}
public function set($setting) {
$this->ws->set($setting);
$this->server->set($setting);
}
public function addListener($host, $port) {
$this->ws->addListener($host, $port);
$this->server->addListener($host, $port);
}
public function start() {
$this->set_ws_handle($this->ws);
$this->ws->on('request', array($this, 'handle'));
$this->ws->start();
$this->set_ws_handle($this->server);
$this->server->on('request', array($this, 'handle'));
$this->server->start();
}
}
}

0 comments on commit 2508222

Please sign in to comment.