本文整理汇总了PHP中Protocol::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Protocol::parse方法的具体用法?PHP Protocol::parse怎么用?PHP Protocol::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Protocol
的用法示例。
在下文中一共展示了Protocol::parse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process_handshake
/**
* Processes an RPC handshake.
* @param AvroIOBinaryDecoder $decoder Where to read from
* @param AvroIOBinaryEncoder $encoder Where to write to.
* @param Transceiver $transceiver the transceiver used for the response
* @return AvroProtocol The requested Protocol.
*/
public function process_handshake(AvroIOBinaryDecoder $decoder, AvroIOBinaryEncoder $encoder, Transceiver $transceiver)
{
if ($transceiver->is_connected()) {
return $transceiver->get_remote();
}
$handshake_request = $this->handshake_responder_reader->read($decoder);
$client_hash = $handshake_request["clientHash"];
$client_protocol = $handshake_request["clientProtocol"];
$remote_protocol = $this->get_protocol_cache($client_hash);
if (is_null($remote_protocol) && !is_null($client_protocol)) {
$remote_protocol = Protocol::parse($client_protocol);
$this->set_protocol_cache($client_hash, $remote_protocol);
}
$server_hash = $handshake_request["serverHash"];
$handshake_response = array();
if ($this->local_hash == $server_hash) {
$handshake_response['match'] = is_null($remote_protocol) ? 'NONE' : 'BOTH';
} else {
$handshake_response['match'] = is_null($remote_protocol) ? 'NONE' : 'CLIENT';
}
$handshake_response["meta"] = null;
if ($handshake_response['match'] != 'BOTH') {
$handshake_response["serverProtocol"] = $this->local_protocol->__toString();
$handshake_response["serverHash"] = $this->local_hash;
} else {
$handshake_response["serverProtocol"] = null;
$handshake_response["serverHash"] = null;
}
$this->handshake_responder_writer->write($handshake_response, $encoder);
if ($handshake_response['match'] != 'NONE') {
$transceiver->set_remote($remote_protocol);
}
return $remote_protocol;
}