The JSON-RPC connection is disconnected for any of these scenarios:
- The
JsonRpc.Dispose
method is invoked. - The transport unexpectedly closes.
- A message is received that does not parse to a valid JSON-RPC message, or some other protocol-level violation is detected.
When any of the above conditions are met, JsonRpc
will (in no particular order):
- Call
Dispose
on theIJsonRpcMessageHandler
, which is expected to dispose the underlying transport. - Faults all outstanding
Task
objects that represent outbound requests with aConnectionLostException
. - If
CancelLocallyInvokedMethodsWhenConnectionIsClosed
istrue
, cancel allCancellationToken
s that were provided as arguments to locally invoked methods. - Remove event handlers that may have been added to any target objects.
- Completes the
Task
returned from theJsonRpc.Completion
property, either succesfully or with the exception that led to the connection termination. - Raise the
JsonRpc.Disconnected
event, with an argument specifying the reason for the disconnection.