コード例 #1
0
        private void Sock_OnPacketsReceived(IPacketSend arg1, Queue <BasePacket> listOfPackets)
        {
            // all of these boolean checks should be replaced by a Strategy
            if (isBoundToGateway == true)
            {
                if (isLoggedIn == true)
                {
                    HandleNormalPackets(listOfPackets);
                }
                else
                {
                    foreach (var packet in listOfPackets)
                    {
                        Console.WriteLine("normal packet received {0} .. isLoggedIn = false", packet.PacketType);
                        LoginCredentialValid lcr = packet as LoginCredentialValid;
                        if (lcr != null)
                        {
                            LoginClientReady temp = (LoginClientReady)IntrepidSerialize.TakeFromPool(PacketType.LoginClientReady);
                            Send(temp);

                            ClientGameInfoResponse cgir = (ClientGameInfoResponse)IntrepidSerialize.TakeFromPool(PacketType.ClientGameInfoResponse);
                            cgir.GameId = (int)applicationId;
                            Send(cgir);

                            isLoggedIn = lcr.isValid;
                        }

                        /*    if (localPlayer.entityId == 0)// until we are assigned an entity id, we can't do much
                         *  {
                         *      EntityPacket ep = packet as EntityPacket;
                         *      if (ep != null)
                         *      {
                         *          localPlayer.entityId = ep.entityId;
                         *      }
                         *  }*/

                        numPacketsReceived++;
                    }
                }
            }
            else
            {
                foreach (var packet in listOfPackets)
                {
                    numPacketsReceived++;
                    if (packet is ServerIdPacket)
                    {
                        ServerIdPacket id = packet as ServerIdPacket;
                        if (id != null && id.Type == ServerIdPacket.ServerType.Gateway)
                        {
                            isBoundToGateway = true;
                            break;
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void HandleLoginCredentialsValidPacket(LoginCredentialValid packet)
        {
            IsLoggedIn = packet.isValid;
            if (IsLoggedIn)
            {
                // Tell the server that we're ready for moar data
                LoginClientReady temp = (LoginClientReady)IntrepidSerialize.TakeFromPool(PacketType.LoginClientReady);
                Send(temp);
                ClientGameInfoResponse cgir = (ClientGameInfoResponse)IntrepidSerialize.TakeFromPool(PacketType.ClientGameInfoResponse);
                cgir.GameId = ApplicationId;
                Send(cgir);
            }
            else
            {
                // Allows us to try to login again
                hasSentCredentials = false;
            }

            OnLoginResponse?.Invoke(new LoginResponse(packet.isValid));
        }
コード例 #3
0
ファイル: GatewayMain.cs プロジェクト: mkawick/Gateway
        public void NewPlayerLoginResult(PlayerConnectionState playerConnection, bool success, PlayerSaveState save)
        {
            if (success == true)
            {
                int connectionId = nextGateWayPlayerConnectionId++;

                GatewayPlayer gp = new GatewayPlayer(connectionId, this, playerConnection, save.accountId);
                playerConnection.finishedLoginSuccessfully = success;

                // Get the server instance id
                lock (connectedLock)
                {
                    players.Add(gp);
                }

                PassSaveStateToGameServer(playerConnection.gameId, connectionId, save);
                gp.HasNotifiedGameServer = true;
            }
            LoginCredentialValid lcv = (LoginCredentialValid)IntrepidSerialize.TakeFromPool(PacketType.LoginCredentialValid);

            lcv.isValid = success;

            playerConnection.Send(lcv);
        }