Exemple #1
0
    public void ReadPacket(PacketType pk, NetIncomingMessage incmsg)
    {
        switch (pk)
        {
        case PacketType.Message:
            Message(incmsg);
            break;

        case PacketType.Respawn:
            Respawn(incmsg);
            break;

        case PacketType.SelectShip:
            SelectShip(incmsg);
            break;

        case PacketType.ConfrimSelect:
            ConfrimSelect(incmsg);
            break;

        case PacketType.Register:
            Register(incmsg);
            break;

        case PacketType.Move:
            UpdateMove(incmsg);
            break;

        case PacketType.Disconnect:
            DisconnetPlayer(incmsg);
            break;

        case PacketType.Login:
            Login(incmsg);
            break;

        case PacketType.Connect:
            if (!serverCore.isDedicated())
            {
                Connect(incmsg.ReadString(), incmsg);
            }
            break;

        case PacketType.Refresh:
            NetOutgoingMessage outmsg = serverCore.CreateMessage();
            outmsg.Write((byte)PacketType.Refresh);
            ServerPacketSender.SendMessageTo(outmsg, incmsg.SenderConnection);
            break;
        }
    }