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

View File

@ -6,5 +6,8 @@
public string Port { get; set; } public string Port { get; set; }
public string RedisHost { get; set; } public string RedisHost { get; set; }
public string RedisPort { 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", "path": "../../ASC.Socket.IO",
"port": "9899", "port": "9899",
"redisHost": "", "redisHost": "",
"redisPort": 6379 "redisPort": 6379,
"pingInterval": 60000,
"reconnectAttempts": 3
} }
} }