/** * Deals with all the incoming connections. */ public static function Response($sString) { # Have we timed out? if (self::$iEndTime < time()) { return true; } # Check if this string is a CTCP response. $pInstance = Core::getCurrentInstance(); $pSocket = $pInstance->getCurrentSocket(); $pMessage = $pInstance->internalPortkey($pSocket, $sString); if ($pMessage === null) { return false; } if ($pSocket->isSocketSlave()) { CoreHandler::Unhandled($pInstance, $pMessage); return false; } # Is this the command we want? $aResponse = explode(' ', substr($pMessage->Payload, 1, -1), 2); if ($pMessage->Payload[0] != chr(1) || $pMessage->Numeric != "NOTICE" || $aResponse[0] != self::$sCommand) { Core::Handler($pInstance, $pMessage); return false; } # Yes! It's the command we want - finally! # PS: SPAAAAAAAAAAAAAAAAAAACE! if (isset($aResponse[1])) { self::$sMessage = $aResponse[1]; } else { self::$sMessage = ""; } return true; }
/** * The main handler function. This function delegates * everything. */ public static function Handler(CoreMaster $pInstance, MessageObject $pMessage) { if (isset($pInstance->pEventHandlers->{$pMessage->Numeric})) { $aEventHandlers = $pInstance->pEventHandlers->{$pMessage->Numeric}; foreach ($aEventHandlers as $pEventHandler) { $mReturn = null; switch ($pEventHandler->eventType) { case EVENT_COMMAND: $mReturn = self::CommandHandler($pInstance, $pMessage, $pEventHandler); break; case EVENT_CUSTOM: $mReturn = self::CustomHandler($pInstance, $pMessage, $pEventHandler); break; default: $mReturn = self::DefaultHandler($pInstance, $pMessage, $pEventHandler); break; } if (self::assert($mReturn)) { return true; } } } if ($pMessage->Parts[0] == "ERROR") { return CoreHandler::onServerError($pInstance, $pMessage); } $sNumeric = !is_numeric($pMessage->Numeric) ? $pMessage->Numeric : 'N' . $pMessage->Numeric; if (!method_exists("CoreHandler", $sNumeric)) { return CoreHandler::Unhandled($pInstance, $pMessage); } return CoreHandler::$sNumeric($pInstance, $pMessage); }
/** * The public entry point for all inbound socket communication. */ public function Portkey(CoreSocket $pSocket, $sString) { $pMessage = $this->internalPortkey($pSocket, $sString); if ($pMessage === null) { return false; } if ($pSocket->isSocketSlave()) { return CoreHandler::Unhandled($this, $pMessage); } return Core::Handler($this, $pMessage); }