Beispiel #1
0
    public void OnRecv()
    {
        PacketHeader header;

        for ( ; ;)
        {
            if (2 != recvBuffer.Peek(out header, 2))
            {
                break;
            }

            if (header.size > recvBuffer.Size)
            {
                break;
            }

            // 범위 체크..
            Debug.Log($"{header.type} : {(int)header.type}, packet size : { header.size} ");

            handler[header.type](header, this.recvBuffer, this);

            //recveBuffer.MoveReadHead(header.size);
        }

        recvBuffer.Rewind();
    }
Beispiel #2
0
    public AsyncCallback OnDisconnectComplete()
    {
        AsyncCallback async = default;

        this.state = SessionState.Disconnected;

        this.handler = null;

        return(async);
    }
Beispiel #3
0
    public void OnInit()
    {
        socket     = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        sendBuffer = new C2PayloadVector();
        recvBuffer = new C2PayloadVector();
        handler    = new InitialiPacketHandler();
        socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
        socket.Blocking = true;
        socket.NoDelay  = true;

        this.state = SessionState.Initialized;
    }
Beispiel #4
0
 public void SetHandler(C2PacketHandler packetHandler)
 {
     this.handler = packetHandler;
 }