[TASK] Added the reconnect-flag that works now.
This commit is contained in:
@@ -61,6 +61,16 @@ abstract class Client_AbstractClient {
|
||||
*/
|
||||
abstract public function loadConfig($config);
|
||||
|
||||
/**
|
||||
* Will reset the connectionStatus of the client.
|
||||
* Implementation depends on the client.
|
||||
* Should be used to reset internal variables.
|
||||
* @return void
|
||||
*/
|
||||
public function resetConnectionStatus() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
|
||||
@@ -80,7 +80,24 @@ class Client_ClientManager {
|
||||
foreach($connectionHandlers["read"] AS $connectionHandler) {
|
||||
//handle disconnects
|
||||
if($connectionHandler->isConnected() === FALSE && $connectionHandler->isListening() === FALSE) {
|
||||
//check whether the reconnect-flag is set
|
||||
if($connectionHandler->getReconnect() === TRUE) {
|
||||
//have the connectionHandler do the reconnect.
|
||||
$newConnectionHandler = $connectionHandler->reconnect();
|
||||
//get the client and reset it.
|
||||
$client = $this->clientPool[$connectionHandler->getID()];
|
||||
$client->resetConnectionStatus();
|
||||
//assign the client to the new connectionHandler.
|
||||
$this->clientPool[$newConnectionHandler->getID()] = $client;
|
||||
//get the config and assign it to the new connectionHandler, too.
|
||||
$config = $this->configPool[$connectionHandler->getID()];
|
||||
$this->configPool[$newConnectionHandler->getID()] = $config;
|
||||
//remove old connection
|
||||
$this->removeConnection($connectionHandler);
|
||||
}
|
||||
$this->removeClientForConnectionHandler($connectionHandler);
|
||||
//reconnect or not - this connectionHandler won't do that much.
|
||||
continue;
|
||||
}
|
||||
//handle accepted sockets, adopt them and treat them with care :-)
|
||||
if($connectionHandler->isListening() === TRUE) {
|
||||
|
||||
@@ -21,6 +21,14 @@ class Client_IrcClient extends Client_AbstractClient {
|
||||
function __construct() {
|
||||
$this->nick = "Serena";
|
||||
$this->channels = array();
|
||||
$this->resetConnectionStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Will reset the clients internal variables concerning the connection status.
|
||||
* @return void
|
||||
*/
|
||||
public function resetConnectionStatus() {
|
||||
$this->lines = 0;
|
||||
$this->got_001 = FALSE;
|
||||
$this->joined = FALSE;
|
||||
@@ -34,8 +42,7 @@ class Client_IrcClient extends Client_AbstractClient {
|
||||
*/
|
||||
public function processContentObject($contentObject) {
|
||||
$data = $contentObject->rawData;
|
||||
//echo "[RECV] ".$data;
|
||||
|
||||
echo "[RECV] ".$data;
|
||||
$this->clientManager->sendToGroup("srv", "[#".$this->ID."] ".$data."\r\n\r\n");
|
||||
|
||||
$return = "";
|
||||
|
||||
Reference in New Issue
Block a user