Example #1
0
        public void NewPlayerLoginResult(PlayerConnectionState playerConnection, bool success, PlayerSaveState save)
        {
            if (success == true)
            {
                int connectionId = nextGateWayPlayerConnectionId++;

                UserSocket gp = new UserSocket(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);
        }
Example #2
0
        void MoveServerPacketsIntoOutgoingClients()
        {
            if (extremeLogging == true)
            {
                Console.WriteLine("MoveServerPacketsIntoOutgoingClients");
            }

            List <UserSocket> tempPlayerList;

            lock (connectedLock)
            {
                tempPlayerList = new List <UserSocket>(players);
            }
            foreach (var server in servers)
            {
                if (server.HasNewData() == true)
                {
                    List <BasePacket> newData = server.RetrieveData();
                    numServerPackets += newData.Count;
                    foreach (var packet in newData)
                    {
                        if (packet is ServerConnectionHeader)
                        {
                            currentConnectionIdForHeader = (packet as ServerConnectionHeader).connectionId;
                            currentPlayerForHeader       = FindPlayer(currentConnectionIdForHeader, tempPlayerList);

                            if (currentPlayerForHeader == null)
                            {
                                ClientDisconnectPacket clientDisconnect = (ClientDisconnectPacket)IntrepidSerialize.TakeFromPool(PacketType.ClientDisconnect);
                                clientDisconnect.connectionId = currentConnectionIdForHeader;
                                Console.WriteLine("Disconnecting connectionId (1): " + clientDisconnect.connectionId);
                                server.Send(clientDisconnect);
                                server.skipNextPacket = true;
                            }
                            else
                            {
                                server.skipNextPacket = false;
                            }

                            IntrepidSerialize.ReturnToPool(packet);
                        }
                        else
                        {
                            if (currentPlayerForHeader != null)
                            {
                                if (packet.PacketType == PacketType.ServerPingHopper)
                                {
                                    string name = Assembly.GetCallingAssembly().GetName().Name;
                                    (packet as ServerPingHopperPacket).Stamp(name + ": game to client");
                                }
                                // copy packet
                                currentPlayerForHeader.connection.Send(packet);

                                //Reset state for next packet pair.
                                currentPlayerForHeader       = null;
                                currentConnectionIdForHeader = 0;
                            }
                            else
                            {
                                if (!server.skipNextPacket)
                                {
                                    Console.WriteLine("Received packet without ServerConnectionHeader packet: {0} from {1} with id {2}", packet, server.serverType, server.gameId);
                                }
                                else
                                {
                                    server.skipNextPacket = false;
                                }
                                IntrepidSerialize.ReturnToPool(packet);
                            }
                        }
                    }
                }
            }
        }