SignalGo/SignalGo-full-net

Provide ConnectionState property similar to SignalR

Closed this issue · 5 comments

With SignalR you have HubConnectionState enum to check state to see if you are connected.

Please support something similar in your library.

do you want check client state in client side? or server side?

Curently I need to write this to check connection state in client:

_clientProvider.ConnectAsyncAutoReconnect("URL:PORT/SignalGo", ConnectedAction);

 void ConnectedAction(bool b)
 {
      lock (_lockObject)
      {
          _isClientConnected = b;
      }
 }

and check for _isClientConnected and call ConnectAsyncAutoReconnect again if false.

No you don't need, in your application ConnectAsyncAutoReconnect must call one time, it will automatically try to connect if disconnected from server, and every time if connection lost or connection successfully your "ConnectedAction" will called with a boolean value that is true or false, true = connected and false = disconnected.

ok, I just noticed that there is a property public bool IsConnected { get; internal set; } to check if connected. Again, without documentation, it is extremely difficult to use your library and find what I look for.

But I would still prefer an enum with also showing Reconnecting state like Signal Core 3

use this example:

 clientProvider.OnConnectionChanged = (status) =>
            {
                if (status == ConnectionStatus.Connected || status == ConnectionStatus.Reconnected)
                {
                    //connected
                }
                else if (status == ConnectionStatus.Reconnecting)
                {
                    //reconnecting
                }
                else if (status == ConnectionStatus.Disconnected)
                {
                    //disconnected
                }
            };