예제 #1
0
        public ProtocolSocket(Socket socket)
        {
            Socket = socket;

            _stream = new NetworkStream(socket, false);

            _sendStream = new BufferMemoryStream(_sendBuffer = new byte[MaxBufferSize]);

            _receiveStream = new BufferMemoryStream(_receiveBuffer = new byte[MaxBufferSize]);

            Decoders[PacketType.SendPayload]                 = () => OnSendPayload?.Invoke(this, _receiveBuffer, HeaderLength, _contentLength);
            Decoders[PacketType.C2S_KeepAlive]               = () => C2S_OnKeepAlive?.Invoke(this);
            Decoders[PacketType.S2C_StartNewConnection]      = () => S2C_OnStartNewConnection?.Invoke(this, _receiveStream.ReadInt32(), _receiveStream.ReadUInt16(), _receiveStream.ReadUInt16());
            Decoders[PacketType.C2S_StartRelay]              = () => C2S_OnStartRelay?.Invoke(this, _receiveStream.ReadInt32());
            Decoders[PacketType.C2S_StartNewConnectionReply] = () => C2S_OnStartNewConnectionReply?.Invoke(this, _receiveStream.ReadInt32(), _receiveStream.ReadUInt16(), _receiveStream.ReadBoolean());
            Decoders[PacketType.S2C_KeepAlive]               = () => S2C_OnKeepAlive?.Invoke(this);
        }
예제 #2
0
파일: Util.cs 프로젝트: araex/RailgunNet
 public virtual void SendPayload(ArraySegment <byte> buffer)
 {
     OnSendPayload?.Invoke(buffer);
 }