Socket.IO: Move pingInterval and reconnectAttempts to config

This commit is contained in:
Alexey Safronov 2022-02-09 12:11:39 +03:00
parent caff06ab95
commit c62d42de80
3 changed files with 11 additions and 4 deletions

View File

@ -48,9 +48,8 @@ namespace ASC.Socket.IO.Svc
[Singletone]
public class SocketServiceLauncher : IHostedService
{
private const int PingInterval = 10000;
private const int ReconnectAttempts = 5;
private int PingInterval { get; set; }
private int ReconnectAttempts { get; set; }
private Process Proc { get; set; }
private ProcessStartInfo StartInfo { get; set; }
private SocketIO SocketClient { get; set; }
@ -85,6 +84,9 @@ namespace ASC.Socket.IO.Svc
{
var settings = ConfigurationExtension.GetSetting<SocketSettings>("socket");
PingInterval = settings.PingInterval.GetValueOrDefault(10000);
ReconnectAttempts = settings.ReconnectAttempts.GetValueOrDefault(5);
StartInfo = new ProcessStartInfo
{
CreateNoWindow = false,

View File

@ -6,5 +6,8 @@
public string Port { get; set; }
public string RedisHost { get; set; }
public string RedisPort { get; set; }
public int? PingInterval { get; set; }
public int? ReconnectAttempts { get; set; }
}
}

View File

@ -3,6 +3,8 @@
"path": "../../ASC.Socket.IO",
"port": "9899",
"redisHost": "",
"redisPort": 6379
"redisPort": 6379,
"pingInterval": 60000,
"reconnectAttempts": 3
}
}