using System.Collections.Concurrent; using DotNetty.Transport.Channels; using log4net; namespace HybirdFrameworkDriver.Session; public class IoSession { private static readonly ILog Log = LogManager.GetLogger(typeof(IoSession)); public IoSession(IChannel channel) { Channel = channel; IpAddr = ChannelUtils.GetIp(channel); } public IChannel Channel { get; } private string IpAddr { get; } public string Key { get; set; } private bool Reconnected { get; set; } //业务数据 public ConcurrentDictionary BusinessMap { get; } = new(); public void Send(Object buffer) { Channel.WriteAndFlushAsync(buffer); } public bool IsClosed() { return !Channel.Open || !Channel.Active; } public void Close() { Channel?.CloseAsync(); } }