/**
  * 连接服务注册中心
  * @return void
  */
 public function connectToRegister()
 {
     $this->_registerConnection = new AsyncTcpConnection("text://{$this->registerAddress}");
     $this->_registerConnection->send('{"event":"worker_connect"}');
     $this->_registerConnection->onClose = array($this, 'onRegisterConnectionClose');
     $this->_registerConnection->onMessage = array($this, 'onRegisterConnectionMessage');
     $this->_registerConnection->connect();
 }
Пример #2
0
 /**
  * 向Register发送心跳,用来保持长连接
  */
 public function pingRegister()
 {
     if ($this->_registerConnection) {
         $this->_registerConnection->send('{"event":"ping"}');
     }
 }