public static function destroy() { if (!empty(IRCServerChannel::$channels)) { foreach (IRCServerChannel::$channels as $channel) { $channel->online = FALSE; $channel->server = NULL; } } if (self::$server_connection->connected) { debug_print_backtrace(); self::$server_connection->send_immediate('QUIT :Fatal Error'); } self::$server_connection->connected = FALSE; self::$server_connection->online = FALSE; self::$server_connection = NULL; }
/** * Creates a new outbound buffer resource and connects to the server * * @param String Server to connect to * @param String Port to connect to * @param String Nickname to use * @param Array List of channels to join */ public function __construct($server, $port, $nickname, $channels, $debug = FALSE) { if (!empty(self::$server_connection) && self::$server_connection->connected) { $this->online = FALSE; $this->connected = FALSE; throw new IRCServerException('You cannot connect to more than one server at a time!'); } set_time_limit(0); register_shutdown_function(array('IRCServerConnection', 'destroy')); $this->buffer = array(); $this->server = $server; $this->port = $port; $this->nick = $nickname; $this->debug = $debug; self::$server_connection = $this; try { $this->connect($channels); } catch (IRCServerException $e) { $this->online = FALSE; $this->connected = FALSE; throw $e; } }