/** @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()'); } } }