/**
  * Forces the server to refresh its configuration.
  *
  * @since 5.1
  * @return string Server result string.
  */
 public function refresh()
 {
     try {
         $result = '';
         $auth = ModuleServerAuthenticator::instance('ModuleServerAuthenticator');
         $this->socket->connect($this->host, $this->port);
         $request = 'REFRESH Module/1.0' . "\r\n";
         $request .= 'User: admin' . "\r\n";
         $request .= 'Password: '******'admin') . "\r\n";
         $this->socket->write($request);
         $result = $this->socket->readAll();
         $this->socket->disconnect();
     } catch (\Innomatic\Net\Socket\SocketException $e) {
         $result = 'Module server is down.' . "\n";
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * force the ModuleServiceSocketHandler to refresh the registry
  *
  * @since 5.1
  */
 protected function force_refresh()
 {
     print "force_refresh" . "\n";
     $request = '';
     $address = '127.0.0.1';
     $context = \Innomatic\Module\Server\ModuleServerContext::instance('\\Innomatic\\Module\\Server\\ModuleServerContext');
     try {
         $port = $context->getConfig()->getKey('service_port');
         $this->socket->connect($address, $port);
         $request = 'REFRESH Module/1.1' . "\r\n";
         $request .= 'User: admin' . "\r\n";
         $request .= 'Password: '******'admin') . "\r\n";
         $this->socket->write($request);
         $result = $this->socket->readAll();
         $this->socket->disconnect();
     } catch (\Innomatic\Net\Socket\SocketException $e) {
         print "Cannot refresh: server " . $address . ":" . $port . " down!" . "\n";
     }
     print $result;
 }
Ejemplo n.º 3
0
 /**
  * @expectedException \Beanie\Exception\SocketException
  * @expectedExceptionCode 333
  * @expectedExceptionMessage test
  */
 public function testDisconnect_recreateSocketFails_throwsException()
 {
     $this->_getNativeFunctionMock()->expects($this->exactly(2))->method('socket_create')->with(AF_INET, SOCK_STREAM, SOL_TCP)->willReturnOnConsecutiveCalls(true, false);
     $this->_getNativeFunctionMock()->expects($this->atLeastOnce())->method('socket_close');
     $this->_setSocketError(333, 'test');
     $socket = new Socket();
     $socket->disconnect();
 }