Example #1
0
    void ProcessBuffer(Client client)
    {
        int end = buffer[client.id].Count;

        foreach (PacketData packet in buffer[client.id])
        {
            try
            {
                switch (packet.type)
                {
                /*case (int)ClientPackets.welcomeReceived:
                 *  ServerHandle.WelcomeReceived(client.id, packet.packet);
                 *  break;*/
                case (int)ClientPackets.login:
                    ServerHandle.Login(client.id, packet.packet);
                    break;

                case (int)ClientPackets.playerMovement:
                    ServerHandle.PlayerMovement(client.id, packet.packet);
                    break;

                case (int)ClientPackets.joystick:
                    ServerHandle.Joystick(client.id, packet.packet);
                    break;

                case (int)ClientPackets.position:
                    ServerHandle.Position(client.id, packet.packet);
                    break;

                case (int)ClientPackets.test:
                    ServerHandle.test(client.id, packet.packet);
                    break;

                case (int)ClientPackets.getInventory:
                    ServerHandle.GetInventory(client.id, packet.packet);
                    break;

                case (int)ClientPackets.dropItem:
                    ServerHandle.DropItem(client.id, packet.packet);
                    break;

                case (int)ClientPackets.dragAndDrop:
                    ServerHandle.DragAndDrop(client.id, packet.packet);
                    break;

                case (int)ClientPackets.searchChest:
                    ServerHandle.SearchChest(client.id, packet.packet);
                    break;

                case (int)ClientPackets.getShipEquipment:
                    ServerHandle.GetShipEquipment(client.id, packet.packet);
                    break;

                case (int)ClientPackets.replaceShipEquipment:
                    ServerHandle.ReplaceShipEquipment(client.id, packet.packet);
                    break;

                case (int)ClientPackets.unequipItem:
                    ServerHandle.UnequipItem(client.id, packet.packet);
                    break;

                case (int)ClientPackets.removeItemFromInventory:
                    ServerHandle.RemoveItemFromInventory(client.id, packet.packet);
                    break;

                case (int)ClientPackets.getPlayerEquipment:
                    ServerHandle.GetPlayerEquipment(client.id, packet.packet);
                    break;

                case (int)ClientPackets.replacePlayerEquipment:
                    ServerHandle.ReplacePlayerEquipment(client.id, packet.packet);
                    break;

                /*case (int)ClientPackets.onGameStart:
                 *  ServerHandle.OnGameStart(client.id, packet.packet);
                 *  break;*/
                case (int)ClientPackets.shoot:
                    ServerHandle.Shoot(client.id, packet.packet);
                    break;

                case (int)ClientPackets.cannonRotate:
                    ServerHandle.CannonRotate(client.id, packet.packet);
                    break;

                case (int)ClientPackets.collectLoot:
                    ServerHandle.CollectLoot(client.id, packet.packet);
                    break;

                case (int)ClientPackets.discardLoot:
                    ServerHandle.DiscardLoot(client.id, packet.packet);
                    break;

                case (int)ClientPackets.chatMessage:
                    ServerHandle.ChatMessage(client.id, packet.packet);
                    break;

                case (int)ClientPackets.createGroup:
                    ServerHandle.CreateGroup(client.id, packet.packet);
                    break;

                case (int)ClientPackets.getGroupList:
                    ServerHandle.GetGroupList(client.id, packet.packet);
                    break;

                case (int)ClientPackets.applyToGroup:
                    ServerHandle.ApplyToGroup(client.id, packet.packet);
                    break;

                case (int)ClientPackets.acceptGroupApplicant:
                    ServerHandle.AcceptGroupApplicant(client.id, packet.packet);
                    break;

                case (int)ClientPackets.declineGroupApplicant:
                    ServerHandle.DeclineGroupApplicant(client.id, packet.packet);
                    break;

                case (int)ClientPackets.kickGroupMember:
                    ServerHandle.KickGroupMember(client.id, packet.packet);
                    break;

                case (int)ClientPackets.leaveGroup:
                    ServerHandle.LeaveGroup(client.id, packet.packet);
                    break;

                case (int)ClientPackets.getPlayerList:
                    ServerHandle.GetPlayerList(client.id, packet.packet);
                    break;

                case (int)ClientPackets.invitePlayer:
                    ServerHandle.InvitePlayer(client.id, packet.packet);
                    break;

                case (int)ClientPackets.acceptGroupInvitation:
                    ServerHandle.AcceptGroupInvitation(client.id, packet.packet);
                    break;

                case (int)ClientPackets.declineGroupInvitation:
                    ServerHandle.DeclineGroupInvitation(client.id, packet.packet);
                    break;

                case (int)ClientPackets.leaveEnterShip:
                    ServerHandle.LeaveEnterShip(client.id, packet.packet);
                    break;

                case (int)ClientPackets.playerInputs:
                    ServerHandle.PlayerInputs(client.id, packet.packet);
                    break;

                case (int)ClientPackets.animationInputs:
                    ServerHandle.AnimationInputs(client.id, packet.packet);
                    break;

                case (int)ClientPackets.mouseX:
                    ServerHandle.MouseX(client.id, packet.packet);
                    break;

                case (int)ClientPackets.gatherResource:
                    ServerHandle.GatherResource(client.id, packet.packet);
                    break;

                case (int)ClientPackets.playerSkills:
                    ServerSend.PlayerSkills(client.id);
                    break;

                case (int)ClientPackets.craftSelected:
                    ServerHandle.CraftSelected(client.id, packet.packet);
                    break;

                case (int)ClientPackets.cancelCrafting:
                    ServerHandle.CancelCrafting(client.id, packet.packet);
                    break;

                case (int)ClientPackets.requestCrafting:
                    ServerHandle.RequestCrafting(client.id, packet.packet);
                    break;

                case (int)ClientPackets.traderInventoryRequest:
                    ServerHandle.TraderInventoryRequest(client.id, packet.packet);
                    break;

                case (int)ClientPackets.buyItem:
                    ServerHandle.BuyItem(client.id, packet.packet);
                    break;

                case (int)ClientPackets.sellItem:
                    ServerHandle.SellItem(client.id, packet.packet);
                    break;

                case (int)ClientPackets.tradeBrokerRequest:
                    ServerHandle.TradeBrokerRequest(client.id, packet.packet);
                    break;

                case (int)ClientPackets.readTradeBrokerItems:
                    ServerHandle.ReadTradeBrokerItems(client.id, packet.packet);
                    break;

                case (int)ClientPackets.registerItemOnBroker:
                    ServerHandle.RegisterItemOnBroker(client.id, packet.packet);
                    break;

                case (int)ClientPackets.removeItemFromBroker:
                    ServerHandle.RemoveItemFromBroker(client.id, packet.packet);
                    break;

                case (int)ClientPackets.buyItemFromBroker:
                    ServerHandle.BuyItemFromBroker(client.id, packet.packet);
                    break;

                case (int)ClientPackets.collectFromBroker:
                    ServerHandle.CollectFromBroker(client.id, packet.packet);
                    break;

                case (int)ClientPackets.tradeRequest:
                    ServerHandle.TradeRequest(client.id, packet.packet);
                    break;

                case (int)ClientPackets.acceptTrade:
                    ServerHandle.AcceptTrade(client.id, packet.packet);
                    break;

                case (int)ClientPackets.declineTrade:
                    ServerHandle.DeclineTrade(client.id, packet.packet);
                    break;

                case (int)ClientPackets.cancelPlayerTrade:
                    ServerHandle.CancelPlayerTrade(client.id, packet.packet);
                    break;

                case (int)ClientPackets.playerTradeAddItem:
                    ServerHandle.PlayerTradeAddItem(client.id, packet.packet);
                    break;

                case (int)ClientPackets.playerTradeRemoveItem:
                    ServerHandle.PlayerTradeRemoveItem(client.id, packet.packet);
                    break;

                case (int)ClientPackets.playerTradeGoldChanged:
                    ServerHandle.PlayerTradeGoldChanged(client.id, packet.packet);
                    break;

                case (int)ClientPackets.playerTradeAccept:
                    ServerHandle.PlayerTradeAccept(client.id, packet.packet);
                    break;

                case (int)ClientPackets.isOnShip:
                    ServerHandle.IsOnShip(client.id, packet.packet);
                    break;

                case (int)ClientPackets.switchTarget:
                    ServerHandle.SwitchTarget(client.id, packet.packet);
                    break;

                case (int)ClientPackets.playerCharacterPosition:
                    ServerHandle.PlayerCharacterPosition(client.id, packet.packet);
                    break;

                case (int)ClientPackets.jump:
                    ServerHandle.Jump(client.id, packet.packet);
                    break;

                case (int)ClientPackets.startCrafting:
                    ServerSend.StartCrafting(client.id);
                    break;

                case (int)ClientPackets.stopCrafting:
                    ServerSend.StopCrafting(client.id);
                    break;

                case (int)ClientPackets.shipPosition:
                    ServerHandle.ShipPosition(client.id, packet.packet);
                    break;

                case (int)ClientPackets.addBuff:
                    ServerHandle.AddBuff(client.id, packet.packet);
                    break;

                case (int)ClientPackets.animationTranslate:
                    ServerHandle.AnimationTranslate(client.id, packet.packet);
                    break;

                case (int)ClientPackets.ping:
                    ServerHandle.Ping(client.id, packet.packet);
                    break;

                case (int)ClientPackets.loadLoot:
                    ServerHandle.LoadLoot(client.id, packet.packet);
                    break;

                case (int)ClientPackets.switchWeaponHands:
                    ServerHandle.SwitchWeaponHands(client.id, packet.packet);
                    break;
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("NetworkManager.cs ProcessBuffer(): " + ex.Message + " " + ex.StackTrace);
            }
        }

        buffer[client.id].RemoveRange(0, end);
    }