You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
866 B

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