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