12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using CommonLang.ByteOrder;
- using CommonLang.Net;
- using SuperSocket.Facility.Protocol;
- using SuperSocket.SocketBase;
- using SuperSocket.SocketBase.Command;
- using SuperSocket.SocketBase.Protocol;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace CommonServer.SSocket.SuperSocket
- {
- public class MessageReceiveFilterFactory : IReceiveFilterFactory<BinaryRequestInfo>
- {
- public MessageReceiveFilterFactory(INetPackageCodec codec)
- {
- }
- public IReceiveFilter<BinaryRequestInfo> CreateFilter(IAppServer appServer, IAppSession appSession, System.Net.IPEndPoint remoteEndPoint)
- {
- return new MessageReceiveFilter(appServer, appSession as Session);
- }
- }
- public class MessageReceiveFilter : FixedHeaderReceiveFilter<BinaryRequestInfo>
- {
- public MessageReceiveFilter(IAppServer appServer, Session appSession)
- : base(4)
- {
- }
- protected override int GetBodyLengthFromHeader(byte[] header, int offset, int length)
- {
- int pos = offset;
- int bodyLength = LittleEdian.GetS32(header, ref pos);
- return bodyLength;
- }
- protected override BinaryRequestInfo ResolveRequestInfo(ArraySegment<byte> header, byte[] bodyBuffer, int offset, int length)
- {
- byte[] bin = new byte[length];
- Buffer.BlockCopy(bodyBuffer, offset, bin, 0, length);
- return new BinaryRequestInfo("BinCommand", bin);
- }
- }
- }
|