- // @TODO We need to somehow detect the state/status of the remote peer and still maintain good speed.
- // @TODO So maybe some pre-instancing of classes might help here to speedup this I/O intensive process.
- $this->partialStub('errorCode=' . $errorCode . ',rawData[] = ' . gettype($rawData) . '(' . strlen($rawData) . ')');
+ // Create a state instance based on $errorCode. This factory does the hard work for us
+ $stateInstance = PeerStateFactory::createPeerStateInstanceByErrorCode($errorCode, $packageData, $socketResource);
+
+ // Return the prepared instance
+ return $stateInstance;