using SuperSocket.SocketBase;
|
using SuperSocket.SocketBase.Protocol;
|
using System.Text;
|
|
namespace Plugin.StandardTest.Setting
|
{
|
public class DTReceiveFilter : ReceiveFilterBase<StringRequestInfo>
|
{
|
public override StringRequestInfo Filter(byte[] readBuffer, int offset, int length, bool toBeCopied, out int rest)
|
{
|
rest = 0;
|
int i = offset;
|
List<byte> bytes = new List<byte>();
|
while (i < readBuffer.Length)
|
{
|
byte b = readBuffer[i++];
|
if (b == '\n')
|
{
|
break;
|
}
|
bytes.Add(b);
|
}
|
byte[] arr = bytes.ToArray();
|
return new StringRequestInfo(DateTime.Now.ToString("yyyyMMddHHmmssfff"), Encoding.UTF8.GetString(arr), null);//sb.ToString()
|
}
|
}
|
|
public class StringParser : IRequestInfoParser<StringRequestInfo>
|
{
|
|
public StringRequestInfo ParseRequestInfo(string source)
|
{
|
return new StringRequestInfo(DateTime.Now.ToString("yyyyMMddHHmmssfff"), source, null);
|
}
|
}
|
|
public class TcpServer : AppServer<TcpSession>
|
{
|
public TcpServer() : base(new TerminatorReceiveFilterFactory("\n", Encoding.UTF8, new StringParser()))
|
{
|
|
}
|
}
|
|
public class TcpSession : AppSession<TcpSession, StringRequestInfo>
|
{
|
|
}
|
}
|