morozovsk\websocket\GenericEvent::start PHP Method

start() public method

public start ( )
    public function start()
    {
        $this->onStart();
        $this->base = new \EventBase();
        if ($this->_server) {
            $this->event = new \EventListener($this->base, array($this, "accept"), $this->base, \EventListener::OPT_CLOSE_ON_FREE | \EventListener::OPT_REUSEABLE, -1, $this->_server);
            //EventListener($this->base, array($this, "accept"), null, \EventListener::OPT_CLOSE_ON_FREE | \EventListener::OPT_REUSEABLE, -1, $this->_server);
        }
        if ($this->_service) {
            $this->service_event = new \EventListener($this->base, array($this, "service"), $this->base, \EventListener::OPT_CLOSE_ON_FREE | \EventListener::OPT_REUSEABLE, -1, $this->_service);
            //EventListener($this->base, array($this, "accept"), null, \EventListener::OPT_CLOSE_ON_FREE | \EventListener::OPT_REUSEABLE, -1, $this->_server);
        }
        if ($this->_master) {
            $connectionId = $this->getIdByConnection($this->_master);
            $buffer = new \EventBufferEvent($this->base, $this->_master, \EventBufferEvent::OPT_CLOSE_ON_FREE);
            $buffer->setCallbacks(array($this, "onRead"), array($this, "onWrite"), array($this, "onError"), $connectionId);
            $buffer->enable(\Event::READ | \Event::WRITE | \Event::PERSIST);
            $this->buffers[$connectionId] = $buffer;
        }
        if ($this->timer) {
            $timer = \Event::timer($this->base, function () use(&$timer) {
                $timer->addTimer($this->timer);
                $this->onTimer();
            });
            $timer->addTimer($this->timer);
        }
        $this->base->dispatch();
    }