123456789101112131415161718192021222324252627282930 |
- using DotNetty.Buffers;
- using DotNetty.Transport.Channels;
- using System;
- using System.Text;
- using System.Threading.Tasks;
- namespace Team.Communicate
- {
- public abstract class AbstractTcpConnector
- {
- protected IByteBuffer ByteBuffers;
- private Encoding _encoding;
-
- public virtual Encoding Encoding
- {
- get => _encoding ?? Encoding.UTF8;
- set => _encoding = value;
- }
- public virtual void SetEnd(string endWith)
- {
- var bytes = Encoding.GetBytes(endWith);
- var sendBytes = Unpooled.Buffer();
- sendBytes.WriteBytes(bytes);
- ByteBuffers = sendBytes;
- }
- public abstract void UseUnRegisterMessage(string key);
- public abstract void Register(string id, Func<string, IChannelHandlerContext, ValueTask<string>> func);
- public abstract void UnRegister(string id);
- }
- }
|