Esempio n. 1
0
        public void ProcessUnloggedIn(BasePacket packet)
        {
            var packetType = packet.PacketType;

            if (packetType == PacketType.LoginCredentials)
            {
                LoginCredentials lc = packet as LoginCredentials;

                //credentialsReceived = true;
                //SendInitData(this);
            }
            else if (packetType == PacketType.LoginClientReady)
            {
                LoginClientReady lc = packet as LoginClientReady;
                loginComplete = true;
                // signal game server that player has logged in.
                // Also, all other servers should be signalled. Once we have a real login server, then the gateway will not need to do any of this.
            }
            else if (packetType == PacketType.ClientGameInfoResponse)
            {
                ClientGameInfoResponse lc = packet as ClientGameInfoResponse;
                gameId = lc.GameId;
            }
            IntrepidSerialize.ReturnToPool(packet);
        }
Esempio n. 2
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;
                        }
                    }
                }
            }
        }
Esempio n. 3
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));
        }