示例#1
0
 public function Open()
 {
     if (!$this->RconSocket) {
         $this->RconSocket = @FSockOpen($this->Socket->Address, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout);
         if ($ErrNo || !$this->RconSocket) {
             throw new SocketException('Can\'t connect to RCON server: ' . $ErrStr, SocketException::CONNECTION_FAILED);
         }
         Stream_Set_Timeout($this->RconSocket, $this->Socket->Timeout);
         Stream_Set_Blocking($this->RconSocket, true);
     }
 }
示例#2
0
 public function Open()
 {
     if (!$this->RconSocket) {
         $this->RconSocket = @FSockOpen($this->Socket->Ip, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout);
         if ($ErrNo || !$this->RconSocket) {
             throw new TimeoutException('Can\'t connect to RCON server: ' . $ErrStr, TimeoutException::TIMEOUT_CONNECT);
         }
         Stream_Set_Timeout($this->RconSocket, $this->Socket->Timeout);
         Stream_Set_Blocking($this->RconSocket, true);
     }
 }
示例#3
0
 public function Open()
 {
     if (!$this->RconSocket && $this->Socket->Engine == CI_SourceQuery::SOURCE) {
         $this->RconSocket = @FSockOpen($this->Socket->Ip, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout);
         if ($ErrNo || !$this->RconSocket) {
             throw new SourceQueryException('Can\'t connect to RCON server: ' . $ErrStr);
         }
         Stream_Set_Timeout($this->RconSocket, $this->Socket->Timeout);
         Stream_Set_Blocking($this->RconSocket, true);
     }
 }
 public function Connect($Ip, $Port = 25575, $Password, $Timeout = 3)
 {
     $this->RequestId = 0;
     if ($this->Socket = FSockOpen($Ip, (int) $Port)) {
         Socket_Set_TimeOut($this->Socket, $Timeout);
         if (!$this->Auth($Password)) {
             $this->Disconnect();
         } else {
             return true;
         }
     }
 }
示例#5
0
 public function Connect($Ip, $Port = 25575, $Password, $Timeout = 3)
 {
     $this->RequestId = 0;
     if ($this->Socket = @FSockOpen($Ip, (int) $Port)) {
         Socket_Set_TimeOut($this->Socket, $Timeout);
         if (!$this->Auth($Password)) {
             $this->Disconnect();
             throw new MinecraftRconException("Authorization failed, password is wrong.");
         }
     } else {
         throw new MinecraftRconException("Can`t connect to MC server.");
     }
 }
示例#6
0
 public function Connect($Ip, $Port = 25575, $Password, $Timeout = 3)
 {
     $this->RequestId = 0;
     if ($this->Socket = @FSockOpen($Ip, (int) $Port, $errno, $errstr, $Timeout)) {
         Socket_Set_TimeOut($this->Socket, $Timeout);
         if (!$this->Auth($Password)) {
             $this->Disconnect();
             throw new MinecraftRconException("Authorization failed.");
         }
     } else {
         throw new MinecraftRconException("Server offline");
     }
 }
 public function Connect($Ip, $Port = 25575, $Password, $Timeout = 3)
 {
     $this->RequestId = 0;
     if ($this->Socket == FSockOpen($Ip, (int) $Port)) {
         Socket_Set_TimeOut($this->Socket, $Timeout);
         if (!$this->Auth($Password)) {
             $this->Disconnect();
             throw new MinecraftRconException("Неудалось авторизироваться.");
         }
     } else {
         throw new MinecraftRconException("Сервер недоступен.");
     }
 }
 public function Connect($Ip, $Port = 25575, $Password, $Timeout = 3)
 {
     $this->RequestId = 0;
     if ($this->Socket = FSockOpen($Ip, (int) $Port)) {
         Socket_Set_TimeOut($this->Socket, $Timeout);
         if (!$this->Auth($Password)) {
             $this->Disconnect();
             throw new MinecraftRconException("Authorization failed.");
         }
     } else {
         throw new MinecraftQueryException("Can't open socket.");
     }
 }
示例#9
0
 public function Open($Address, $Port, $Timeout, $Engine)
 {
     $this->Timeout = $Timeout;
     $this->Engine = $Engine;
     $this->Port = $Port;
     $this->Address = $Address;
     $this->Socket = @FSockOpen('udp://' . $Address, $Port, $ErrNo, $ErrStr, $Timeout);
     if ($ErrNo || $this->Socket === false) {
         throw new SocketException('Could not create socket: ' . $ErrStr, SocketException::COULD_NOT_CREATE_SOCKET);
     }
     Stream_Set_Timeout($this->Socket, $Timeout);
     Stream_Set_Blocking($this->Socket, true);
 }
示例#10
0
 public function Open($Ip, $Port, $Timeout, $Engine)
 {
     $this->Timeout = $Timeout;
     $this->Engine = $Engine;
     $this->Port = $Port;
     $this->Ip = $Ip;
     $this->Socket = @FSockOpen('udp://' . $Ip, $Port, $ErrNo, $ErrStr, $Timeout);
     if ($ErrNo || $this->Socket === false) {
         throw new Exception('Could not create socket: ' . $ErrStr);
     }
     Stream_Set_Timeout($this->Socket, $Timeout);
     Stream_Set_Blocking($this->Socket, true);
     return true;
 }
示例#11
0
 public function Connect($Ip, $Port = 25565, $Timeout = 3)
 {
     if ($this->Socket = FSockOpen('udp://' . $Ip, (int) $Port)) {
         Socket_Set_TimeOut($this->Socket, $Timeout);
         $Challenge = $this->GetChallenge();
         if ($Challenge === false) {
             FClose($this->Socket);
             return false;
         }
         if (!$this->GetStatus($Challenge)) {
             FClose($this->Socket);
             return false;
         }
         FClose($this->Socket);
         return true;
     } else {
         return false;
     }
 }
 public function Connect($Ip, $Port = 25565, $Timeout = 3)
 {
     if (!is_int($Timeout) || $Timeout < 0) {
         throw new InvalidArgumentException('Timeout must be an integer.');
     }
     $this->Socket = @FSockOpen('udp://' . $Ip, (int) $Port, $ErrNo, $ErrStr, $Timeout);
     if ($ErrNo || $this->Socket === false) {
         throw new MinecraftQueryException('Could not create socket: ' . $ErrStr);
     }
     Stream_Set_Timeout($this->Socket, $Timeout);
     Stream_Set_Blocking($this->Socket, true);
     try {
         $Challenge = $this->GetChallenge();
         $this->GetStatus($Challenge);
     } catch (MinecraftQueryException $e) {
         FClose($this->Socket);
         throw new MinecraftQueryException($e->getMessage());
     }
     FClose($this->Socket);
 }