Protocol
class Protocol
Properties
| protected bool | $connected | ||
| protected bool | $connecting | ||
| protected int | $nextRequestId | ||
| protected NegotiatedConnection|null | $connection | ||
| protected ResponseCache|null | $cache |
Methods
Create a protocol connection for the transport.
Determine whether the connection has completed negotiation.
Get the legacy initialization result.
Get the modern discovery result.
Get the negotiated server capabilities.
Get the server implementation information.
Get the server instructions.
Pin the protocol version and invalidate the existing negotiation.
Get the explicitly selected protocol version.
Connect and negotiate once for concurrent callers.
Negotiate the pinned, remembered or preferred protocol version.
Probe modern discovery before falling back to legacy initialization.
Complete the legacy initialization handshake.
Discover the server and settle on a mutually supported version.
Initialize a mutually supported version from a discovery rejection.
Create an error for a server rejecting the pinned version.
Determine whether an error identifies a modern server.
Determine whether an error permits a legacy handshake.
Disconnect the transport after any active negotiation finishes.
Get the configured response cache.
Get the headers required by the selected protocol version.
Send a notification without overlapping connection mutations.
Get the currently negotiated protocol version.
Apply the protocol version to transports that use it.
Reply to server requests supported by the transport.
Details
at line 57
__construct(Transport $transport, Implementation $clientInfo, ProtocolVersion|null $pinnedProtocolVersion = null)
Create a protocol connection for the transport.
at line 67
bool
connected()
Determine whether the connection has completed negotiation.
at line 75
InitializeResult|null
initializeResult()
Get the legacy initialization result.
at line 83
DiscoverResult|null
discoverResult()
Get the modern discovery result.
at line 93
array
capabilities()
Get the negotiated server capabilities.
at line 101
Implementation|null
serverInfo()
Get the server implementation information.
at line 109
string|null
instructions()
Get the server instructions.
at line 117
void
pinProtocolVersion(ProtocolVersion|null $protocolVersion)
Pin the protocol version and invalidate the existing negotiation.
at line 132
ProtocolVersion|null
pinnedProtocolVersion()
Get the explicitly selected protocol version.
at line 140
void
connect()
Connect and negotiate once for concurrent callers.
at line 178
protected void
handshake()
Negotiate the pinned, remembered or preferred protocol version.
at line 216
protected NegotiatedConnection
probe()
Probe modern discovery before falling back to legacy initialization.
at line 258
protected NegotiatedConnection
initialize(ProtocolVersion $protocolVersion, bool $pinned = false)
Complete the legacy initialization handshake.
at line 278
protected NegotiatedConnection
discover(ProtocolVersion|null $pinned = null)
Discover the server and settle on a mutually supported version.
at line 304
protected NegotiatedConnection
retryWithMutualVersion(JsonRpcException $jsonRpcException)
Initialize a mutually supported version from a discovery rejection.
at line 323
protected ClientException
versionMismatch(ProtocolVersion $settled, ProtocolVersion $pinned)
Create an error for a server rejecting the pinned version.
at line 335
protected bool
identifiesModernServer(JsonRpcException $jsonRpcException)
Determine whether an error identifies a modern server.
at line 347
protected bool
identifiesLegacyServer(JsonRpcException $jsonRpcException)
Determine whether an error permits a legacy handshake.
at line 361
void
disconnect()
Disconnect the transport after any active negotiation finishes.
at line 382
array
dispatch(Method $method)
Dispatch a method, using the response cache when configured.
at line 398
void
useCache(ResponseCache|null $responseCache)
Set the response cache for this client.
at line 406
ResponseCache|null
cache()
Get the configured response cache.
at line 417
protected array
roundTrip(Method $method)
Send a complete request, retrying an expired session once.
at line 450
protected array
attempt(Method $method, ProtocolVersion $protocolVersion)
Send a request and consume its matching terminal response.
at line 546
protected array
requestHeaders(Method $method, JsonRpcRequest $request, ProtocolVersion $protocolVersion)
Get the headers required by the selected protocol version.
at line 564
protected array
params(Method $method, ProtocolVersion $protocolVersion)
Add protocol metadata to the method parameters when required.
at line 585
void
notify(string $method, ProtocolVersion|null $protocolVersion = null)
Send a notification without overlapping connection mutations.
at line 613
ProtocolVersion
connectionProtocol()
Get the currently negotiated protocol version.
at line 625
protected void
configureTransport(ProtocolVersion $protocolVersion)
Apply the protocol version to transports that use it.
at line 637
protected void
handleServerRequest(array $frame)
Reply to server requests supported by the transport.