mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 12:15:01 +00:00
?
This commit is contained in:
@@ -474,6 +474,8 @@ namespace PepperDash.Essentials
|
||||
WSClient = new WebSocketClient();
|
||||
}
|
||||
WSClient.URL = string.Format("wss://{0}/system/join/{1}", Config.ServerUrl, this.SystemUuid);
|
||||
WSClient.ConnectionCallBack = ConnectCallback;
|
||||
WSClient.DisconnectCallBack = DisconnectCallback;
|
||||
WSClient.Connect();
|
||||
Debug.Console(0, this, "Websocket connected");
|
||||
WSClient.ReceiveCallBack = WebsocketReceiveCallback;
|
||||
@@ -481,6 +483,43 @@ namespace PepperDash.Essentials
|
||||
WSClient.ReceiveAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Waits two and goes again
|
||||
/// </summary>
|
||||
void ReconnectStreamClient()
|
||||
{
|
||||
WSClient = null;
|
||||
new CTimer(o => ConnectStreamClient(), 2000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
int ConnectCallback(WebSocketClient.WEBSOCKET_RESULT_CODES code)
|
||||
{
|
||||
if (code != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
|
||||
{
|
||||
Debug.Console(1, this, "Web socket connection failed: {0}", code);
|
||||
ReconnectStreamClient();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
int DisconnectCallback(WebSocketClient.WEBSOCKET_RESULT_CODES code, object o)
|
||||
{
|
||||
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Websocket disconnected with code: {0}", code);
|
||||
ReconnectStreamClient();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resets reconnect timer and updates usercode
|
||||
/// </summary>
|
||||
@@ -619,7 +658,7 @@ namespace PepperDash.Essentials
|
||||
}
|
||||
case "held":
|
||||
{
|
||||
if (!PushedActions.ContainsKey(type))
|
||||
if (PushedActions.ContainsKey(type))
|
||||
{
|
||||
PushedActions[type].Reset(ButtonHeartbeatInterval, ButtonHeartbeatInterval);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user