diff --git a/HybirdFrameworkDriver/TcpServer/ServerListenerHandler.cs b/HybirdFrameworkDriver/TcpServer/ServerListenerHandler.cs index 0f5eb06..82d6f06 100644 --- a/HybirdFrameworkDriver/TcpServer/ServerListenerHandler.cs +++ b/HybirdFrameworkDriver/TcpServer/ServerListenerHandler.cs @@ -25,7 +25,7 @@ namespace HybirdFrameworkDriver.TcpServer public override void ChannelActive(IChannelHandlerContext context) { base.ChannelActive(context); - SessionMgr.RegisterSession(context.Channel.Id.ToString(), new IoSession(context.Channel)); + SessionMgr.RegisterSession(context.Channel, new IoSession(context.Channel)); Log.Info("active " + context.Channel); } diff --git a/HybirdFrameworkDriver/TcpServer/SessionMgr.cs b/HybirdFrameworkDriver/TcpServer/SessionMgr.cs index da1a56f..6bf8b0e 100644 --- a/HybirdFrameworkDriver/TcpServer/SessionMgr.cs +++ b/HybirdFrameworkDriver/TcpServer/SessionMgr.cs @@ -12,12 +12,13 @@ public class SessionMgr private static readonly ConcurrentDictionary Dictionary = new ConcurrentDictionary(); - public static void RegisterSession(string key, IoSession ioSession) + public static void RegisterSession(IChannel channel, IoSession ioSession) { - ioSession.Key = key; + ioSession.Key = channel.Id.ToString(); IoSession? session; Dictionary.Remove(ioSession.Key, out session); - Dictionary.AddOrUpdate(key, ioSession, (k, oldSession) => ioSession); + ChannelUtils.AddChannelSession(channel, ioSession); + Dictionary.AddOrUpdate(channel.Id.ToString(), ioSession, (k, oldSession) => ioSession); } public static void UnregisterSession(IChannel channel)