handle socket exception on connect
This commit is contained in:
		@@ -283,6 +283,15 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
 | 
				
			|||||||
		$this->requestQuit("ManiaControl Shutdown requested by '{$player->login}'!");
 | 
							$this->requestQuit("ManiaControl Shutdown requested by '{$player->login}'!");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Request ManiaControl to quit
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param mixed $message
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public function requestQuit($message = true) {
 | 
				
			||||||
 | 
							$this->requestQuitMessage = $message;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Run ManiaControl
 | 
						 * Run ManiaControl
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
@@ -336,8 +345,11 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			$this->client = Connection::factory($this->server->config->host, $this->server->config->port, self::SCRIPT_TIMEOUT, $this->server->config->user, $this->server->config->pass, self::API_VERSION);
 | 
								$this->client = Connection::factory($this->server->config->host, $this->server->config->port, self::SCRIPT_TIMEOUT, $this->server->config->user, $this->server->config->pass, self::API_VERSION);
 | 
				
			||||||
		} catch (AuthenticationException $e) {
 | 
							} catch (TransportException $exception) {
 | 
				
			||||||
			$message = "Couldn't authenticate on Server with User '{$this->server->config->user}' & Pass '{$this->server->config->pass}'! " . $e->getMessage();
 | 
								$message = "Couldn't connect to the server: '{$exception->getMessage()}'";
 | 
				
			||||||
 | 
								$this->quit($message, true);
 | 
				
			||||||
 | 
							} catch (AuthenticationException $exception) {
 | 
				
			||||||
 | 
								$message = "Couldn't authenticate on Server with User '{$this->server->config->user}' & Pass '{$this->server->config->pass}'! " . $exception->getMessage();
 | 
				
			||||||
			$this->quit($message, true);
 | 
								$this->quit($message, true);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -401,13 +413,4 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
 | 
				
			|||||||
	public function handleServerStopCallback() {
 | 
						public function handleServerStopCallback() {
 | 
				
			||||||
		$this->requestQuit('The Server has been shut down!');
 | 
							$this->requestQuit('The Server has been shut down!');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * Request ManiaControl to quit
 | 
					 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @param mixed $message
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public function requestQuit($message = true) {
 | 
					 | 
				
			||||||
		$this->requestQuitMessage = $message;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user