[TASK] Updated variable names to lowerCamelCase.
This commit is contained in:
parent
78866ed149
commit
df030e453d
@ -167,6 +167,63 @@ class Client_ClientManager {
|
||||
unset($this->registeredProtocols[$protocol]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches a configuration to a connection.
|
||||
* Will overwrite the existing configuration for the connection.
|
||||
* @param array $config
|
||||
* @param Connection_ConnectionHandler $connectionHandler
|
||||
* @return void
|
||||
*/
|
||||
public function attachConfig($config, $connectionHandler) {
|
||||
$this->configPool[$connectionHandler->getID()] = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls Connection_Pool
|
||||
* @see Connection_ConnectionPool
|
||||
* @param int $id
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function sendToID($id, $data) {
|
||||
return $this->connectionPool->writeToID($id, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of available connection IDs.
|
||||
* @return array
|
||||
*/
|
||||
public function getIDs() {
|
||||
$list = array();
|
||||
foreach($this->connectionPool->getConnectionHandlers() AS $connectionHandler) {
|
||||
$list[] = $connectionHandler->getID();
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of available connection groups.
|
||||
* @return array
|
||||
*/
|
||||
public function getGroups() {
|
||||
$list = array();
|
||||
foreach($this->connectionPool->getConnectionHandlers() AS $connectionHandler) {
|
||||
$list[] = $connectionHandler->getGroup();
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls Connection_Pool
|
||||
* @see Connection_ConnectionPool
|
||||
* @param string $group
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function sendToGroup($group, $data) {
|
||||
return $this->connectionPool->writeToGroup($group, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for the registered client for the given protocol.
|
||||
* Returns a client instance or void.
|
||||
@ -258,62 +315,5 @@ class Client_ClientManager {
|
||||
$this->connectionPool->removeConnectionHandler($connectionHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches a configuration to a connection.
|
||||
* Will overwrite the existing configuration for the connection.
|
||||
* @param array $config
|
||||
* @param Connection_ConnectionHandler $connectionHandler
|
||||
* @return void
|
||||
*/
|
||||
public function attachConfig($config, $connectionHandler) {
|
||||
$this->configPool[$connectionHandler->getID()] = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls Connection_Pool
|
||||
* @see Connection_ConnectionPool
|
||||
* @param int $id
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function sendToID($id, $data) {
|
||||
return $this->connectionPool->writeToID($id, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of available connection IDs.
|
||||
* @return array
|
||||
*/
|
||||
public function getIDs() {
|
||||
$list = array();
|
||||
foreach($this->connectionPool->getConnectionHandlers() AS $connectionHandler) {
|
||||
$list[] = $connectionHandler->getID();
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of available connection groups.
|
||||
* @return array
|
||||
*/
|
||||
public function getGroups() {
|
||||
$list = array();
|
||||
foreach($this->connectionPool->getConnectionHandlers() AS $connectionHandler) {
|
||||
$list[] = $connectionHandler->getGroup();
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls Connection_Pool
|
||||
* @see Connection_ConnectionPool
|
||||
* @param string $group
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function sendToGroup($group, $data) {
|
||||
return $this->connectionPool->writeToGroup($group, $data);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -16,7 +16,7 @@ class Connection_ConnectionHandler {
|
||||
* This buffer does not use a linebreak, it's a temporary store for data.
|
||||
* @var Misc_Buffer
|
||||
*/
|
||||
protected $buffer_incoming;
|
||||
protected $bufferIncoming;
|
||||
|
||||
/**
|
||||
* Buffer that contains outgoing data.
|
||||
@ -24,7 +24,7 @@ class Connection_ConnectionHandler {
|
||||
* This buffer does not use a linebreak, it's a temporary store for data.
|
||||
* @var Misc_Buffer
|
||||
*/
|
||||
protected $buffer_outgoing;
|
||||
protected $bufferOutgoing;
|
||||
|
||||
/**
|
||||
* Contains the instance of the SocketHandler class.
|
||||
@ -42,7 +42,7 @@ class Connection_ConnectionHandler {
|
||||
* A boolean that indicates whether this Connection is a listening server socket or a usual client socket.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $is_server;
|
||||
protected $isServer;
|
||||
|
||||
/**
|
||||
* Unique Connection ID.
|
||||
@ -79,7 +79,7 @@ class Connection_ConnectionHandler {
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
protected $reconnect_on_disconnect;
|
||||
protected $reconnectOnDisconnect;
|
||||
|
||||
/**
|
||||
* Calls parent constructor.
|
||||
@ -88,16 +88,16 @@ class Connection_ConnectionHandler {
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($socket, $id, $group = "", $protocol = "") {
|
||||
$this->buffer_incoming = new Misc_Buffer();
|
||||
$this->buffer_outgoing = new Misc_Buffer();
|
||||
$this->bufferIncoming = new Misc_Buffer();
|
||||
$this->bufferOutgoing = new Misc_Buffer();
|
||||
$this->socketHandler = new Socket_SocketHandler($socket);
|
||||
$this->id = $id;
|
||||
$this->group = $group;
|
||||
$this->protocol = $protocol;
|
||||
$this->is_server = FALSE;
|
||||
$this->isServer = FALSE;
|
||||
$this->host = "";
|
||||
$this->port = 0;
|
||||
$this->reconnect_on_disconnect = FALSE;
|
||||
$this->reconnectOnDisconnect = FALSE;
|
||||
$this->IPv6 = FALSE;
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ class Connection_ConnectionHandler {
|
||||
* @return boolean
|
||||
*/
|
||||
public function isServer() {
|
||||
return $this->is_server;
|
||||
return $this->isServer;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,20 +157,20 @@ class Connection_ConnectionHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets reconnect_on_disconnect flag.
|
||||
* Sets reconnectOnDisconnect flag.
|
||||
* @param boolean $reconnect
|
||||
* @return void
|
||||
*/
|
||||
public function setReconnect($reconnect) {
|
||||
$this->reconnect_on_disconnect = $reconnect;
|
||||
$this->reconnectOnDisconnect = $reconnect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets reconnect_on_disconnect flag.
|
||||
* Gets reconnectOnDisconnect flag.
|
||||
* @return boolean
|
||||
*/
|
||||
public function getReconnect() {
|
||||
return $this->reconnect_on_disconnect;
|
||||
return $this->reconnectOnDisconnect;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,7 +184,7 @@ class Connection_ConnectionHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads from SocketHandler, writes into buffer_incoming.
|
||||
* Reads from SocketHandler, writes into bufferIncoming.
|
||||
* Returns a boolean that will indicate whether the socket is still okay.
|
||||
* @throws Exception_SocketException
|
||||
* @return boolean
|
||||
@ -196,18 +196,18 @@ class Connection_ConnectionHandler {
|
||||
$this->shutdown();
|
||||
return FALSE;
|
||||
}
|
||||
$this->buffer_incoming->addData($data);
|
||||
$this->bufferIncoming->addData($data);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the buffer_outgoing to the SocketHandler.
|
||||
* Writes the bufferOutgoing to the SocketHandler.
|
||||
* Returns a boolean that will indicate whether the socket is still okay.
|
||||
* @throws Exception_SocketException
|
||||
* @return boolean
|
||||
*/
|
||||
public function writeFromBuffer() {
|
||||
$bufferContent = $this->buffer_outgoing->getAllBufferContents();
|
||||
$bufferContent = $this->bufferOutgoing->getAllBufferContents();
|
||||
//this might not be cool, but it should do.
|
||||
if($bufferContent === "") return TRUE;
|
||||
$result = $this->socketHandler->write($bufferContent);
|
||||
@ -232,7 +232,7 @@ class Connection_ConnectionHandler {
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead() {
|
||||
return $this->buffer_incoming->hasData();
|
||||
return $this->bufferIncoming->hasData();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,26 +240,26 @@ class Connection_ConnectionHandler {
|
||||
* @return boolean
|
||||
*/
|
||||
public function canWrite() {
|
||||
return $this->buffer_outgoing->hasData();
|
||||
return $this->bufferOutgoing->hasData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads new data into buffer_incoming.
|
||||
* Returns a full line from buffer_incoming.
|
||||
* Reads new data into bufferIncoming.
|
||||
* Returns a full line from bufferIncoming.
|
||||
* @return string
|
||||
*/
|
||||
public function read() {
|
||||
return $this->buffer_incoming->getAllBufferContents();
|
||||
return $this->bufferIncoming->getAllBufferContents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes data into buffer_outgoing.
|
||||
* Sends data from buffer_outgoing to the SocketHandler.
|
||||
* Writes data into bufferOutgoing.
|
||||
* Sends data from bufferOutgoing to the SocketHandler.
|
||||
* @param $data
|
||||
* @return void
|
||||
*/
|
||||
public function write($data) {
|
||||
$this->buffer_outgoing->addData($data);
|
||||
$this->bufferOutgoing->addData($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -324,7 +324,7 @@ class Connection_ConnectionHandler {
|
||||
* @return Connection_ConnectionHandler
|
||||
*/
|
||||
public function reconnect() {
|
||||
if($this->reconnect_on_disconnect === FALSE) throw new Exception_GeneralException("Cannot reconnect: Reconnect-Flag not set!", 1290951385);
|
||||
if($this->reconnectOnDisconnect === FALSE) throw new Exception_GeneralException("Cannot reconnect: Reconnect-Flag not set!", 1290951385);
|
||||
if(empty($this->host) === TRUE) throw new Exception_GeneralException("Cannot reconnect: No host specified.", 1290950818);
|
||||
if(empty($this->port) === TRUE) throw new Exception_GeneralException("Cannot reconnect: No port specified.", 1290950844);
|
||||
$newConnectionHandler = $this->connectionPool->createTcpConnection($this->group, $this->protocol, $this->IPv6);
|
||||
@ -352,7 +352,7 @@ class Connection_ConnectionHandler {
|
||||
* @return void
|
||||
*/
|
||||
public function listen() {
|
||||
$this->is_server = TRUE;
|
||||
$this->isServer = TRUE;
|
||||
return $this->socketHandler->listen();
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ class Exception_GeneralException extends Exception {
|
||||
$string = get_class($this);
|
||||
$string .= " :" . $this->message;
|
||||
$string .= " in " . $this->file . "(" . $this->line . ")";
|
||||
$string .= "\n" . $this->getTraceAsString();
|
||||
$string .= PHP_EOL . $this->getTraceAsString();
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class Misc_Buffer {
|
||||
//no need to do this when there are no linebreaks.
|
||||
if($this->linebreak === "") return;
|
||||
if(strpos($this->buffer, $this->linebreak) === FALSE) return;
|
||||
$has_linebreak_at_end = (substr($this->buffer, (-1) * strlen($this->linebreak)) === $this->linebreak) ? TRUE : FALSE;
|
||||
$hasLinebreakAtEnd = (substr($this->buffer, (-1) * strlen($this->linebreak)) === $this->linebreak) ? TRUE : FALSE;
|
||||
$lines = explode($this->linebreak, $this->buffer);
|
||||
foreach($lines AS $key=>$line) {
|
||||
$line = str_replace($this->linebreak, "", $line);
|
||||
@ -46,7 +46,7 @@ class Misc_Buffer {
|
||||
if($line === "") unset($lines[$key]);
|
||||
}
|
||||
$this->buffer = implode($this->linebreak, $lines);
|
||||
if($has_linebreak_at_end) $this->buffer .= $this->linebreak;
|
||||
if($hasLinebreakAtEnd === TRUE) $this->buffer .= $this->linebreak;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,18 +15,18 @@ abstract class Protocol_AbstractProtocolHandler {
|
||||
* Buffer for data that was received by the Client.
|
||||
* @var Misc_Buffer
|
||||
*/
|
||||
protected $buffer_incoming;
|
||||
protected $bufferIncoming;
|
||||
|
||||
/**
|
||||
* Buffer for data that will be sent by the Client.
|
||||
* @var Misc_Buffer
|
||||
*/
|
||||
protected $buffer_outgoing;
|
||||
protected $bufferOutgoing;
|
||||
|
||||
/**
|
||||
* This function will be called by the constructor.
|
||||
* It will create the necessary instances of Misc_Buffer and
|
||||
* put them in $buffer_incoming and $buffer_outgoing.
|
||||
* put them in $bufferIncoming and $bufferOutgoing.
|
||||
* @return void
|
||||
*/
|
||||
abstract public function createBuffers();
|
||||
@ -49,7 +49,7 @@ abstract class Protocol_AbstractProtocolHandler {
|
||||
|
||||
/**
|
||||
* Main worker function of the ProtocolHandler.
|
||||
* Will fetch data from the buffer_incoming, process it,
|
||||
* Will fetch data from the bufferIncoming, process it,
|
||||
* and create a ProtocolContentObject out of it that will be returned to the client.
|
||||
* @return mixed instance of Protocol_AbstractProtocolContentObject
|
||||
*/
|
||||
@ -61,7 +61,7 @@ abstract class Protocol_AbstractProtocolHandler {
|
||||
* @return void
|
||||
*/
|
||||
public function pushRawData($rawData) {
|
||||
$this->buffer_incoming->addData($rawData);
|
||||
$this->bufferIncoming->addData($rawData);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,7 +69,7 @@ abstract class Protocol_AbstractProtocolHandler {
|
||||
* @return string
|
||||
*/
|
||||
public function getRawData() {
|
||||
return $this->buffer_outgoing->getAllBufferContents();
|
||||
return $this->bufferOutgoing->getAllBufferContents();
|
||||
}
|
||||
}
|
||||
?>
|
@ -13,8 +13,8 @@ class Protocol_BotProtocolHandler extends Protocol_AbstractProtocolHandler {
|
||||
*/
|
||||
public function createBuffers() {
|
||||
$linebreak = "\r\n";
|
||||
$this->buffer_incoming = new Misc_Buffer($linebreak);
|
||||
$this->buffer_outgoing = new Misc_Buffer($linebreak);
|
||||
$this->bufferIncoming = new Misc_Buffer($linebreak);
|
||||
$this->bufferOutgoing = new Misc_Buffer($linebreak);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -23,7 +23,7 @@ class Protocol_BotProtocolHandler extends Protocol_AbstractProtocolHandler {
|
||||
* @return Protocol_BotProtocolContentObject
|
||||
*/
|
||||
public function work() {
|
||||
$data = $this->buffer_incoming->getNextLine();
|
||||
$data = $this->bufferIncoming->getNextLine();
|
||||
return new Protocol_BotProtocolContentObject($data);
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ class Protocol_BotProtocolHandler extends Protocol_AbstractProtocolHandler {
|
||||
* @return boolean
|
||||
*/
|
||||
public function canWork() {
|
||||
return $this->buffer_incoming->hasLines();
|
||||
return $this->bufferIncoming->hasLines();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,7 +45,7 @@ class Protocol_BotProtocolHandler extends Protocol_AbstractProtocolHandler {
|
||||
* @return void
|
||||
*/
|
||||
public function sendRaw($data) {
|
||||
$this->buffer_outgoing->addData($data);
|
||||
$this->bufferOutgoing->addData($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ class Protocol_IrcProtocolHandler extends Protocol_AbstractProtocolHandler {
|
||||
*/
|
||||
public function createBuffers() {
|
||||
$this->linebreak = "\n";
|
||||
$this->buffer_incoming = new Misc_Buffer($this->linebreak);
|
||||
$this->buffer_outgoing = new Misc_Buffer($this->linebreak);
|
||||
$this->bufferIncoming = new Misc_Buffer($this->linebreak);
|
||||
$this->bufferOutgoing = new Misc_Buffer($this->linebreak);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -31,7 +31,7 @@ class Protocol_IrcProtocolHandler extends Protocol_AbstractProtocolHandler {
|
||||
* @throws Exception_GeneralException
|
||||
*/
|
||||
public function work() {
|
||||
$data = $this->buffer_incoming->getNextLine();
|
||||
$data = $this->bufferIncoming->getNextLine();
|
||||
//create contentObject and set the raw data.
|
||||
$contentObject = new Protocol_IrcProtocolContentObject($data);
|
||||
|
||||
@ -176,7 +176,7 @@ class Protocol_IrcProtocolHandler extends Protocol_AbstractProtocolHandler {
|
||||
* @return boolean
|
||||
*/
|
||||
public function canWork() {
|
||||
return $this->buffer_incoming->hasLines();
|
||||
return $this->bufferIncoming->hasLines();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -187,7 +187,7 @@ class Protocol_IrcProtocolHandler extends Protocol_AbstractProtocolHandler {
|
||||
* @return void
|
||||
*/
|
||||
public function sendRaw($data) {
|
||||
$this->buffer_outgoing->addData($data . $this->linebreak);
|
||||
$this->bufferOutgoing->addData($data . $this->linebreak);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user