/** @Override */
 public function prepareToRead($encodedTokens)
 {
     $this->tokenList = array();
     $this->tokenListIndex = 0;
     $this->stringTable = null;
     $idx = 0;
     while (false !== ($nextIdx = mb_strpos($encodedTokens, self::RPC_SEPARATOR_CHAR, $idx))) {
         $current = mb_substr($encodedTokens, $idx, $nextIdx - $idx);
         $this->tokenList[] = $current;
         $idx = $nextIdx + 1;
     }
     if ($idx == 0) {
         // Didn't find any separator, assume an older version with different
         // separators and get the version as the sequence of digits at the
         // beginning of the encoded string.
         while ($idx < mb_strlen($encodedTokens) && Character::isDigit(mb_substr($encodedTokens, $idx, 1))) {
             ++$idx;
         }
         if ($idx == 0) {
             throw new IncompatibleRemoteException('Malformed or old RPC message received - expecting version between ' . self::SERIALIZATION_STREAM_MIN_VERSION . ' and ' . self::SERIALIZATION_STREAM_VERSION);
         } else {
             $version = Integer::valueOf(mb_substr($encodedTokens, 0, $idx));
             throw new IncompatibleRemoteServiceException('Expecting version between ' . self::SERIALIZATION_STREAM_MIN_VERSION . ' and ' . self::SERIALIZATION_STREAM_VERSION . " from client, got {$version}" . '.');
         }
     }
     parent::prepareToRead($encodedTokens);
     // Check the RPC version number sent by the client
     if ($this->getVersion() < self::SERIALIZATION_STREAM_MIN_VERSION || $this->getVersion() > self::SERIALIZATION_STREAM_VERSION) {
         throw new IncompatibleRemoteServiceException('Expecting version between ' . self::SERIALIZATION_STREAM_MIN_VERSION . ' and ' . self::SERIALIZATION_STREAM_VERSION . ' from client, got ' . $this->getVersion() . '.');
     }
     // Check the flags
     if (!$this->areFlagsValid()) {
         throw new IncompatibleRemoteServiceException('Got an unknown flag from ' . 'client: ' . $this->getFlags());
     }
     // Read the type name table
     $this->deserializeStringTable();
     // Write the serialization policy info
     $moduleBaseURL = $this->readString();
     $strongName = $this->readString();
     if (!is_null($this->serializationPolicyProvider)) {
         $this->serializationPolicy = $this->serializationPolicyProvider->getSerializationPolicy($moduleBaseURL, $strongName);
         if (is_null($this->serializationPolicy)) {
             throw new NullPointerException('serializationPolicyProvider.getSerializationPolicy()');
         }
     }
 }
 public function prepareToRead($encodedTocens)
 {
     $this->tokenList = array();
     $this->tokenListIndex = 0;
     $this->stringTable = null;
     $idx = 0;
     $nextIdx = 0;
     while (false != ($nextIdx = strpos($encodedTocens, CHAR_UFFFF, $idx))) {
         $current = substr($encodedTocens, $idx, $nextIdx - $idx);
         $this->tokenList[] = $current;
         $idx = $nextIdx + 3;
     }
     $this->logger->info($this->tokenList);
     parent::prepareToRead();
     $this->logger->info("Version " . $this->getVersion());
     $this->logger->info("Flags " . $this->getFlags());
     $this->deserializeStringTable();
     $this->logger->info($this->stringTable);
     // If this stream encodes resource file information, read it and get a
     // SerializationPolicy
     if ($this->hasSerializationPolicyInfo()) {
         $moduleBaseURL = $this->readString();
         $strongName = $this->readString();
         $this->logger->info('ModuleBaseURL ' . $moduleBaseURL);
         $this->logger->info('StrongName ' . $strongName);
         // not implemented yet
         //			if ($this->serializationPolicyProvidero !== null) {
         //				$this->serializationPolicy = $this->serializationPolicyProvider->getSerializationPolicy($moduleBaseURL, $strongName);
         //
         //				if ($this->serializationPolicy === null) {
         //					throw new NullPointerException(
         //					"serializationPolicyProvider.getSerializationPolicy()");
         //				}
         //			}
     }
 }