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