|
@@ -13,6 +13,7 @@ use Log;
|
|
|
|
|
|
interface IProcessor
|
|
|
{
|
|
|
+ public function onStart();
|
|
|
public function onRequest($bufid, $body);
|
|
|
public function onClose($bufid);
|
|
|
public function onConnected($bufid,$stream,$host,$port,$args);
|
|
@@ -52,6 +53,7 @@ abstract class srv_base
|
|
|
public function init(IProcessor $processor)
|
|
|
{
|
|
|
$this->mProcessor = $processor;
|
|
|
+ $this->mProcessor->onStart();
|
|
|
}
|
|
|
|
|
|
public function run_loop($sock)
|
|
@@ -65,13 +67,13 @@ abstract class srv_base
|
|
|
Log::record("event_base_loop ret={$ret}",Log::DEBUG);
|
|
|
}
|
|
|
|
|
|
- private function add_listen($fd)
|
|
|
+ private function add_listen($stream)
|
|
|
{
|
|
|
- $fd = intval($fd);
|
|
|
+ $fd = intval($stream);
|
|
|
if($fd < 0) return false;
|
|
|
|
|
|
$this->mEvAccepts[$fd] = event_new();
|
|
|
- if(event_set($this->mEvAccepts[$fd], $fd, EV_READ | EV_PERSIST, [$this, 'onAccept'], $this->mEvBase) == false) {
|
|
|
+ if(event_set($this->mEvAccepts[$fd], $stream, EV_READ | EV_PERSIST, [$this, 'onAccept'], $this->mEvBase) == false) {
|
|
|
Log::record("event_set error EV_READ | EV_PERSIST",Log::DEBUG);
|
|
|
}
|
|
|
|