* String getNumeric()
* returns the Numeric of the Server
*
+ * String getName()
+ * returns the Name of the Server
+ *
+ * String getStartTime()
+ * returns the startup time of the Server
+ *
+ * String getLinkTime()
+ * returns the link time of the Server
+ *
+ * String getDescription()
+ * returns the Description of the Server
+ *
* void addServer(P10_Server $server)
* adds a Server to the server's "slave" list
*
return $this->numeric;
}
+ public function getName() {
+ return $this->name;
+ }
+
+ public function getStartTime() {
+ return $this->start_time;
+ }
+
+ public function getLinkTime() {
+ return $this->link_time;
+ }
+
+ public function getDescription() {
+ return $this->description;
+ }
+
public function addServer($server) {
$this->servers[$server->getNumeric()] = $server;
}
$self_numeric = $this->getSetting("numeric");
$self_name = $this->getSetting("name");
$self_description = $this->getSetting("description");
+ if(!$self_numeric || !$self_name) {
+ trigger_error("Server Settings missing.", E_USER_ERROR);
+ return;
+ }
$this->server = new P10_Server($self_name, $self_numeric, null, time(), time(), $self_description);
}
$state = $this->client->connect($host, $port, $this->getSettings("bind"), $this->getSettings("ssl"), $this->getSettings("recv_timeout"));
if(!$state) {
usleep($this->getSetting("recv_timeout") / 1000);
- $flags |= self::FLAG_NOT_CONNECTABLE;
+ $this->flags |= self::FLAG_NOT_CONNECTABLE;
return;
}
$this->flags = 0;
+ $this->loginServer();
}
//try to receive new data from the Uplink
$lines = $this->client->recv();
}
}
+ private function loginServer() {
+ $password = $this->getSetting("password");
+ $this->send("PASS", $password);
+ $this->send("SERVER", $this->server->getName(), $this->server->getStartTime(), $this->server->getLinkTime(), $this->server->getNumeric(), $this->server->getDescription());
+ }
+
private function parseLine($line) {
$highExplode = explode(" :", $line, 2);
$tokens = explode(" ", $highExplode[0]);
if(count($highExplode) > 1)
$tokens[] = $highExplode[1];
$cmdPos = (($this->flags & self::FLAG_P10SESSION) ? 1 : 0);
- if($tokens[0] == "ERROR") $cmdPos = 0; //override
if($cmdPos == 1) $from = $tokens[0];
else $from = null;
$arguments = array_slice($tokens, $cmdPos + 1);
}
$new_server = new P10_Server($args[0], substr($args[5],0,2), $this->server, $args[2], $args[3], $args[7]);
$this->server->add_server($new_server);
+ $this->flags |= self::FLAG_P10SESSION;
} else {
//another server got a new slave server ^^
$server = P10_Server::getServerByNum($from);