X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fclasses%2Fmain%2Fcontainer%2Fsocket%2Fclass_SocketContainer.php;h=8b70b95421ac708e1e77dfa0ce6710056e3fac44;hb=da1c915e6b217c496f668051f66b8f177175e1bd;hp=eff4ca18d7878d61a04cfa10a55ef55f1a47a462;hpb=9108a2a3b038ee56833f7811accb49fdce2944e8;p=core.git diff --git a/inc/classes/main/container/socket/class_SocketContainer.php b/inc/classes/main/container/socket/class_SocketContainer.php index eff4ca18..8b70b954 100644 --- a/inc/classes/main/container/socket/class_SocketContainer.php +++ b/inc/classes/main/container/socket/class_SocketContainer.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team + * @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 * @@ -36,18 +36,43 @@ class SocketContainer extends BaseContainer implements Registerable { * Creates an instance of this Container class and prepares it for usage * * @param $socketResource A valid socket resource + * @param $protocolInstance A ProtocolHandler instance + * @param $packageData Raw package data * @return $containerInstance An instance of this Container class */ - public final static function createSocketContainer ($socketResource) { + public static final function createSocketContainer ($socketResource, ProtocolHandler $protocolInstance = NULL, array $packageData) { // Get a new instance $containerInstance = new SocketContainer(); - // Set the resource + // Set the resource ... $containerInstance->setSocketResource($socketResource); + // ..., protocol instance ... + $containerInstance->setProtocolInstance($protocolInstance); + + // ... and package data + $containerInstance->setPackageData($packageData); + // Return the prepared instance return $containerInstance; } + + /** + * Checks wether the given address (IP) matches with the one from the socket resource + * + * @param $addressPort The address:port (IP to check + * @return $matches Wether $address matches with the one from socket resource + */ + public final function ifAddressMatches ($addressPort) { + // Get current package data + $data = $this->getPackageData(); + + // So, does both match? + $matches = ((isset($data['recipient'])) && ($data['recipient'] === $addressPort)); + + // Return result + return $matches; + } } // [EOF]