|
|
|
@ -16,17 +16,10 @@ public class SessionMgr
|
|
|
|
|
|
|
|
|
|
public static IoSession? GetSession(string key)
|
|
|
|
|
{
|
|
|
|
|
if (Dictionary.ContainsKey(key))
|
|
|
|
|
{
|
|
|
|
|
IoSession? value;
|
|
|
|
|
Dictionary.TryGetValue(key, out value);
|
|
|
|
|
|
|
|
|
|
Dictionary.TryGetValue(key, out IoSession? value);
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<IoSession> GetSessionList()
|
|
|
|
|
{
|
|
|
|
|
return Dictionary.Values.ToList();
|
|
|
|
@ -59,6 +52,18 @@ public class SessionMgr
|
|
|
|
|
Dictionary.AddOrUpdate(channel.Id.ToString(), ioSession, (k, oldSession) => ioSession);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ChangeSessionKey(IoSession ioSession, string newKey)
|
|
|
|
|
{
|
|
|
|
|
var oldKey = ioSession.Key;
|
|
|
|
|
if (oldKey != null)
|
|
|
|
|
{
|
|
|
|
|
Dictionary.Remove(oldKey, out IoSession? session);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ioSession.Key = newKey;
|
|
|
|
|
Dictionary.AddOrUpdate(newKey, ioSession, (k, oldSession) => ioSession);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void RegisterModbusSession(string key, ModbusSession ioSession)
|
|
|
|
|
{
|
|
|
|
|