Closed ZimM-LostPolygon closed 6 years ago
@enlight Did some changes. Basically: if both clients were provided to the constructor, auto-reconnect will ensure both clients are connected before doing any communication. If only read client was passed (as in the cases you described), write client will be ignored.
Also added an AutoReconnect
property that controls this behavior and made added better exceptions for cases when client is null.
LGTM, thank you :)
Previously, whenever connection was lost for whatever reason (Internet connection loss,
IRpcClient.DisconnectAsync
), there was to no way to explicitly reconnect without doing anything else. Instead, wheneverCallAsync
orStaticCallAsync
was called when disconnected,RpcClient
s would just attempt to silently reconnect. This is not ideal for a few reasons: 1) It might be required to reconnect without immediately sending any data. 2) This behavior hides the "truth" and is different from the usual behavior of socket-like entities. If connection is lost, I would expectCallAsync
to throw an exception immediately, instead of silently attempting to reconnect.This PR solves point 1 by adding a
IRpcClient.ConnectAsync
method.