X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcontainer%2Fsocket%2Fclass_SocketContainer.php;h=cfa66f0d535373c3822671b5920db4708bb1b04b;hp=eff4ca18d7878d61a04cfa10a55ef55f1a47a462;hb=18fd6edc11a36a3e52870f1946499e448a863ea7;hpb=fffe0ef5a4c39831127b1afed64d8ea0e077b09e diff --git a/inc/classes/main/container/socket/class_SocketContainer.php b/inc/classes/main/container/socket/class_SocketContainer.php index eff4ca18..cfa66f0d 100644 --- a/inc/classes/main/container/socket/class_SocketContainer.php +++ b/inc/classes/main/container/socket/class_SocketContainer.php @@ -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 final static function createSocketContainer ($socketResource, ProtocolHandler $protocolInstance, 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]