[TASK] Now using DIRECTORY_SEPERATOR for the few paths we have.
This commit is contained in:
parent
8e32f35edf
commit
f9beef4c81
|
@ -7,7 +7,7 @@
|
|||
* @return void
|
||||
*/
|
||||
function __autoload($className) {
|
||||
$file = "Classes/" . str_replace("_", "/", $className) . ".php";
|
||||
$file = "Classes" . DIRECTORY_SEPARATOR . str_replace("_", DIRECTORY_SEPARATOR, $className) . ".php";
|
||||
if(file_exists($file) === TRUE) {
|
||||
require_once($file);
|
||||
} else {
|
||||
|
|
|
@ -91,7 +91,7 @@ class Socket_SocketHandler {
|
|||
public function connect($address, $port) {
|
||||
if($this->isConnected === TRUE) throw new Exception_SocketException("Socket is already connected!", 1289663170);
|
||||
$result = socket_connect($this->socket, $address, $port);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
$this->isConnected = TRUE;
|
||||
}
|
||||
|
||||
|
@ -105,9 +105,9 @@ class Socket_SocketHandler {
|
|||
public function bind($address, $port) {
|
||||
if($this->isBound === TRUE) throw new Exception_SocketException("Socket is already bound!", 1289663212);
|
||||
$result = socket_set_option($this->socket, SOL_SOCKET, SO_REUSEADDR, 1);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
$result = socket_bind($this->socket, $address, $port);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
$this->isBound = TRUE;
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ class Socket_SocketHandler {
|
|||
public function listen() {
|
||||
if($this->isBound === FALSE) throw new Exception_SocketException("Cannot listen on unbound socket!", 1289663220);
|
||||
$result = socket_listen($this->socket);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
$this->isListening = TRUE;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ class Socket_SocketHandler {
|
|||
if($this->isBound === FALSE) throw new Exception_SocketException("Cannot accept connections from unbound socket!", 1289663239);
|
||||
if($this->isListening === FALSE) throw new Exception_SocketException("Cannot accept connections from socket that is not listening!", 1289663241);
|
||||
$accept = socket_accept($this->socket);
|
||||
if($accept === FALSE) $this->error();
|
||||
if($accept === FALSE) $this->handleSocketError();
|
||||
return $accept;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ class Socket_SocketHandler {
|
|||
public function getRemoteName() {
|
||||
if($this->isConnected === FALSE) throw new Exception_SocketException("Socket not connected, cannot retrieve remote name!", 1289928192);
|
||||
$result = socket_getpeername($this->socket, $address, $port);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
return $address . ":" . $port;
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ class Socket_SocketHandler {
|
|||
public function getLocalName() {
|
||||
if($this->isBound === FALSE ^ $this->isConnected === FALSE) throw new Exception_SocketException("Socket is not bound or connected, no local name available!", 1289928256);
|
||||
$result = socket_getsockname($this->socket, $address, $port);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
return $address . ":" . $port;
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ class Socket_SocketHandler {
|
|||
*/
|
||||
public function write($data) {
|
||||
$result = socket_write($this->socket, $data);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,7 +188,7 @@ class Socket_SocketHandler {
|
|||
*/
|
||||
public function read($length = 16384) {
|
||||
$result = socket_read($this->socket, $length, PHP_BINARY_READ);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -201,11 +201,11 @@ class Socket_SocketHandler {
|
|||
usleep(100000);
|
||||
if($this->isConnected === TRUE) {
|
||||
$result = socket_shutdown($this->socket);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
}
|
||||
if(is_resource($this->socket)) {
|
||||
$result = socket_close($this->socket);
|
||||
if($result === FALSE) $this->error();
|
||||
if($result === FALSE) $this->handleSocketError();
|
||||
}
|
||||
$this->isConnected = FALSE;
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ class Socket_SocketHandler {
|
|||
* @throws Exception_SocketException
|
||||
* @return void
|
||||
*/
|
||||
protected function error() {
|
||||
protected function handleSocketError() {
|
||||
if(is_resource($this->socket) === FALSE) throw new Exception_SocketException("No socket resource available!", 1290954177);
|
||||
$errno = socket_last_error($this->socket);
|
||||
$error = socket_strerror($errno);
|
||||
|
|
2
Main.php
2
Main.php
|
@ -3,7 +3,7 @@ error_reporting(E_ALL);
|
|||
require_once('AutoLoader.php');
|
||||
|
||||
try {
|
||||
require_once('Testcode/Client/ClientManagerTest.php');
|
||||
require_once('Testcode' . DIRECTORY_SEPARATOR . 'Client' . DIRECTORY_SEPARATOR . 'ClientManagerTest.php');
|
||||
}
|
||||
catch(Exception $e) {
|
||||
echo PHP_EOL.PHP_EOL."Caught Exception: " . $e . PHP_EOL;
|
||||
|
|
|
@ -3,16 +3,17 @@ $clientManager = new Client_ClientManager();
|
|||
$clientManager->registerProtocol("irc", "Irc");
|
||||
$clientManager->registerProtocol("jpt", "Bot");
|
||||
|
||||
/*$freenode = $clientManager->createTcpConnection("freenode", "irc");
|
||||
$freenode = $clientManager->createTcpConnection("freenode", "irc");
|
||||
$clientManager->attachConfig(array(
|
||||
"nick" => "Testinstanz",
|
||||
"userident" => "uzuguck",
|
||||
"channels" => array("#mstasty")
|
||||
"nick" => "Pb42|test",
|
||||
"userident" => "lalala",
|
||||
"channels" => array("##available")
|
||||
), $freenode);
|
||||
$freenode->connect("irc.freenode.net", 6667);
|
||||
$freenode->setReconnect(TRUE);
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
$euirc = $clientManager->createTcpConnection("euirc", "irc");
|
||||
$clientManager->attachConfig(array(
|
||||
"nick" => "Pb42",
|
||||
|
@ -21,7 +22,7 @@ $clientManager->attachConfig(array(
|
|||
), $euirc);
|
||||
$euirc->connect("irc.euirc.net", 6667);
|
||||
$euirc->setReconnect(TRUE);
|
||||
|
||||
*/
|
||||
/*$osuIRC = $clientManager->createTcpConnection("osuIRC", "irc");
|
||||
$clientManager->attachConfig(array(
|
||||
"nick" => "Pb42",
|
||||
|
|
Loading…
Reference in New Issue