inc/classes/exceptions/socket/class_InvalidServerSocketException.php svneol=native#text/plain
inc/classes/exceptions/socket/class_InvalidSocketException.php svneol=native#text/plain
inc/classes/exceptions/socket/class_NoSocketRegisteredException.php svneol=native#text/plain
+inc/classes/exceptions/socket/class_SocketConnectionException.php svneol=native#text/plain
+inc/classes/exceptions/socket/class_SocketCreationException.php svneol=native#text/plain
+inc/classes/exceptions/socket/class_SocketOptionException.php svneol=native#text/plain
inc/classes/exceptions/socket/class_SocketShutdownException.php svneol=native#text/plain
inc/classes/exceptions/stacker/.htaccess svneol=native#text/plain
inc/classes/exceptions/stacker/class_AlreadyInitializedStackerException.php svneol=native#text/plain
--- /dev/null
+<?php
+/**
+ * This exception is thrown when socket_connection() could not succeed. This
+ * means a lot: the connection was refused by other peer (no open port; mostly
+ * with TCP connections), broken pipes and so on ...
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class SocketConnectionException extends FrameworkException {
+ /**
+ * A Constructor for this exception
+ *
+ * @param $messageArray Error message array
+ * @param $code Error code
+ * @return void
+ */
+ public function __construct (array $messageData, $code) {
+ // Construct the message
+ $message = sprintf("[%s:] Could not make a connection! (type %s != resource). errno=%s, errstr=%s",
+ $messageData[0]->__toString(),
+ $messageData[1],
+ $messageData[2],
+ $messageData[3]
+ );
+
+ // Call parent exception constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * This exception is thrown when socket_create() returns a variable with
+ * non-resource type. This could mean you don't have propper permission to
+ * create a socket or else. (Sorry I don't know it exactly)
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class SocketCreationException extends FrameworkException {
+ /**
+ * A Constructor for this exception
+ *
+ * @param $messageArray Error message array
+ * @param $code Error code
+ * @return void
+ */
+ public function __construct (array $messageData, $code) {
+ // Construct the message
+ $message = sprintf("[%s:] Cannot create socket (type %s != resource). errno=%s, errstr=%s",
+ $messageData[0]->__toString(),
+ $messageData[1],
+ $messageData[2],
+ $messageData[3]
+ );
+
+ // Call parent exception constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * This exception is thrown when an option could not be set on given socket
+ * resource. This means that the socket could be (somehow) created but cannot
+ * be altered (as usual with non-blocking connections).
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class SocketOptionException extends FrameworkException {
+ /**
+ * A Constructor for this exception
+ *
+ * @param $messageArray Error message array
+ * @param $code Error code
+ * @return void
+ */
+ public function __construct (array $messageData, $code) {
+ // Construct the message
+ $message = sprintf("[%s:] Changing option on socket failed! (type %s != resource). errno=%s, errstr=%s",
+ $messageData[0]->__toString(),
+ $messageData[1],
+ $messageData[2],
+ $messageData[3]
+ );
+
+ // Call parent exception constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
/**
* A Constructor for this exception
*
- * @param $helperInstance A BaseConnectionHelper instance
- * @param $code Error code
+ * @param $helperInstance A ConnectionHelper instance
+ * @param $code Error code
* @return void
*/
- public function __construct (BaseConnectionHelper $helperInstance, $code) {
+ public function __construct (ConnectionHelper $helperInstance, $code) {
// Get socket resource
$socketResource = $helperInstance->getSocketResource();
*/
interface StateResolver extends Resolver {
/**
- * Returns an state instance for a given package class and raw data
+ * Returns an state instance for a given package raw data and socket resource
*
- * @param $packageInstance An instance of a package class
+ * @param $helperInstance An instance of a ConnectionHelper class
* @param $packageData Raw package data
* @param $socketResource A valid socket resource
* @return $stateInstance An instance of the resolved state
*/
- function resolveStateByPackage (Networkable $packageInstance, array $packageData, $socketResource);
+ static function resolveStateByPackage (ConnectionHelper $helperInstance, array $packageData, $socketResource);
/**
* Checks wether the given state is valid
// Exception constants
const EXCEPTION_FILTER_CHAIN_INVALID = 0xf10;
+ // Names of controller's own filter chains
+ const FILTER_CHAIN_PRE_COMMAND = 'controller_pre_command';
+ const FILTER_CHAIN_POST_COMMAND = 'controller_post_command';
+
/**
* Protected constructor
*
parent::__construct($className);
// Initialize both filter chains
- $this->initFilterChain('pre');
- $this->initFilterChain('post');
+ $this->initFilterChain(self::FILTER_CHAIN_PRE_COMMAND);
+ $this->initFilterChain(self::FILTER_CHAIN_POST_COMMAND);
// Add this controller to the registry
Registry::getRegistry()->addInstance('controller', $this);
*/
public function addPreFilter (Filterable $filterInstance) {
// Add the pre filter
- $this->addFilter('pre', $filterInstance);
+ $this->addFilter(self::FILTER_CHAIN_PRE_COMMAND, $filterInstance);
}
/**
*/
public function addPostFilter (Filterable $filterInstance) {
// Add the post filter
- $this->addFilter('post', $filterInstance);
+ $this->addFilter(self::FILTER_CHAIN_POST_COMMAND, $filterInstance);
}
/**
*/
protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) {
// Execute all pre filters
- $this->executeFilters('pre', $requestInstance, $responseInstance);
+ $this->executeFilters(self::FILTER_CHAIN_PRE_COMMAND, $requestInstance, $responseInstance);
}
/**
*/
protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) {
// Execute all post filters
- $this->executeFilters('post', $requestInstance, $responseInstance);
+ $this->executeFilters(self::FILTER_CHAIN_POST_COMMAND, $requestInstance, $responseInstance);
}
}