示例#1
0
        protected override void OnSocketKilled(string msg)
        {
            INetworkConnection con = GetOwningServerConnection();

            if (con != null && con.IsAlive && ServerUser.CurrentCharacter != null)
            {
                PropertyBag bag = new PropertyBag();
                bag.SetProperty((int)PropertyID.CharacterId, ServerUser.CurrentCharacter.CharacterInfo.ID);
                if (ServerUser.TransferTarget != null)
                {
                    bag.SetProperty((int)PropertyID.Name, ServerUser.TransferTarget);
                }
                con.SendGenericMessage((int)GenericMessageType.CharacterDisconnected, bag, false);
            }

            if (ServerUser.TransferTarget == null || ServerUser.TransferTarget.Length == 0) // if we're not transferring
            {
                if (ServerUser.Profile != null && !ServerUser.IsAuthorizedClusterServer)
                {
                    ServerUser.Profile.SetLoggedOut();
                    if (ServerBase.UseDatabaseConnectivity && ServerUser.IsAuthenticated)
                    {
                        ServerUser.Profile.Save(MyServer.RequireAuthentication);
                    }
                }
                // kill auth ticket on this server.
                ConnectionManager.UnAuthorizeUser(ServerUser, false);
            }

            base.OnSocketKilled(msg);
        }
示例#2
0
        /// <summary>
        /// Request a list of all games that the server knows about. This is a non-blocking call. Once the game data arrives, LobbyClient.Games
        /// will have the latest data in it and LobbyClient.CompleteMatchListingArrived event will fire.
        /// </summary>
        /// <param name="msg">a string which will hold player facing text message if the call fails (returns false)</param>
        /// <returns>true if IsGameServerConnected and was ReadyForPlay and the request was thus sent</returns>
        public bool RequestGameListing(ref string msg, int page, int numPerPage, bool includeInProgress, int minPlayersAllowed, PropertyBag parms)
        {
            msg = "";
            if (!IsCentralServerConnected || !CentralReadyForCommunication)
            {
                msg = "Not ready to communicate with game server.";
                return(false);
            }

            Log.LogMsg("Requesting content listing from game server.");
            PropertyBag bag = new PropertyBag();

            bag.SetProperty("Page", page);
            bag.SetProperty("NumPerPage", numPerPage);
            bag.SetProperty("IncludeInProgress", includeInProgress);
            bag.SetProperty("MinPlayersAllowed", minPlayersAllowed);

            // ad-hoc parms
            bag.UpdateWithValues(parms);

            if (GameRequestSearchInvoker != null)
            {
                PropertyBag add = FireGameRequestSearch();
                if (add != null)
                {
                    bag.UpdateWithValues(add);
                }
            }

            m_CentralServer.SendGenericMessage((int)GenericLobbyMessageType.RequestGameListing, bag, false);
            return(true);
        }
示例#3
0
        protected override void OnSocketKilled(string msg)
        {
            INetworkConnection con = GetOwningServerConnection();

            if (con != null && con.IsAlive && ServerUser.CurrentCharacter != null)
            {
                PropertyBag bag = new PropertyBag();
                bag.SetProperty((int)PropertyID.CharacterId, ServerUser.CurrentCharacter.CharacterInfo.ID);
                if (ServerUser.TransferTarget != null)
                {
                    bag.SetProperty((int)PropertyID.Name, ServerUser.TransferTarget);
                }
                con.SendGenericMessage((int)GenericMessageType.CharacterDisconnected, bag, false);
            }

            if (ServerUser.TransferTarget == null || ServerUser.TransferTarget.Length == 0) // if we're not transferring
            {
                if (ServerUser.Profile != null && !ServerUser.IsAuthorizedClusterServer)
                {
                    ServerUser.Profile.SetLoggedOut();
                    if (ServerBase.UseDatabaseConnectivity && ServerUser.IsAuthenticated)
                    {
                        ServerUser.Profile.Save(MyServer.RequireAuthentication);
                    }
                }
                // kill auth ticket on this server.
                ConnectionManager.UnAuthorizeUser(ServerUser, false);
            }

            base.OnSocketKilled(msg);
        }
        private void OnPatchInfoRequest(INetworkConnection con, Packet r)
        {
            PropertyBag bag = new PropertyBag();
            bag.SetProperty("MB", ((PatchServerProcess)MyServer).MBytesPatchDataSent);
            bag.SetProperty("Num", ((PatchServerProcess)MyServer).PatchFileSent);
            bag.SetProperty("Users", ConnectionManager.ConnectionCount);

            PacketGenericMessage msg = r as PacketGenericMessage;
            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms = bag;
        }
示例#5
0
        /// <summary>
        /// Gets called when we are ready to communicate with the player, i.e. we can start sending packets
        /// </summary>
        protected virtual void OnConnectionReady()
        {
            INetworkConnection con = GetOwningServerConnection();

            if (con != null && con.IsAlive && ServerUser.CurrentCharacter != null)
            {
                PropertyBag bag = new PropertyBag();
                bag.SetProperty((int)PropertyID.CharacterInfo, ServerUser.CurrentCharacter as IComponent);
                bag.SetProperty((int)PropertyID.Owner, ServerUser.ID);
                con.SendGenericMessage((int)GenericMessageType.CharacterTransferComplete, bag, false);
            }
        }
示例#6
0
        public TSCharacterComponent()
        {
            ComponentName = "TrueSkill Character Rating Component";
            m_Properties  = new PropertyBag("True Skill Added Properties");

            GameInfo gameInfo    = GameInfo.DefaultGameInfo;
            int      gamesPlayed = 0;

            m_Properties.SetProperty("TS Games Played", (int)TSPropertyID.GamesPlayed, gamesPlayed);
            m_Properties.SetProperty("Initial Mean", (int)TSPropertyID.RatingMean, gameInfo.InitialMean);
            m_Properties.SetProperty("Initial Standard Deviation", (int)TSPropertyID.RatingStandardDeviation, gameInfo.InitialStandardDeviation);
        }
示例#7
0
        /// <summary>
        /// Gets called when we are ready to communicate with the player, i.e. we can start sending packets
        /// </summary>
        protected virtual void OnConnectionReady()
        {
            INetworkConnection con = GetOwningServerConnection();

            if (con != null && con.IsAlive && ServerUser.CurrentCharacter != null)
            {
                PropertyBag bag = new PropertyBag();
                bag.SetProperty((int)PropertyID.CharacterInfo, ServerUser.CurrentCharacter as IComponent);
                bag.SetProperty((int)PropertyID.Owner, ServerUser.ID);
                con.SendGenericMessage((int)GenericMessageType.CharacterTransferComplete, bag, false);
            }
        }
示例#8
0
        public TSCharacterComponent()
        {
            ComponentName = "TrueSkill Character Rating Component";
            m_Properties = new PropertyBag("True Skill Added Properties");

            GameInfo gameInfo = GameInfo.DefaultGameInfo;
            int gamesPlayed = 0;

            m_Properties.SetProperty("TS Games Played", (int)TSPropertyID.GamesPlayed, gamesPlayed);
            m_Properties.SetProperty("Initial Mean", (int)TSPropertyID.RatingMean, gameInfo.InitialMean);
            m_Properties.SetProperty("Initial Standard Deviation", (int)TSPropertyID.RatingStandardDeviation, gameInfo.InitialStandardDeviation);
        }
        private void OnPatchInfoRequest(INetworkConnection con, Packet r)
        {
            PropertyBag bag = new PropertyBag();

            bag.SetProperty("MB", ((PatchServerProcess)MyServer).MBytesPatchDataSent);
            bag.SetProperty("Num", ((PatchServerProcess)MyServer).PatchFileSent);
            bag.SetProperty("Users", ConnectionManager.ConnectionCount);

            PacketGenericMessage msg = r as PacketGenericMessage;

            r.ReplyPacket       = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms = bag;
        }
示例#10
0
        internal static PropertyBag BuildDefaultPropertyBag()
        {
            PropertyBag allOptions = new PropertyBag();

            // The export command could be updated in the future to accept an arbitrary set
            // of analyzers for which to build an options XML file suitable for configuring them.
            // Currently, we perform discovery against the built-in CodeFormatter rules
            // and analyzers only.
            foreach (IOptionsProvider provider in FormattingEngine.GetOptionsProviders(DefaultCompositionAssemblies))
            {
                foreach (IOption option in provider.GetOptions())
                {
                    allOptions.SetProperty(option, option.DefaultValue);
                }
            }

            // TODO: this needs to be fixed. Instead of maintaining a hard-coded list of analyzers, that needs to
            //       be updated on adding a new check, we need to expose the analyzer name on an appropriate interface.
            //       Retrieving each of these bools populates the property bag with the default value of 'true'
            bool enabled;

            foreach (string analyzerName in AllAnalyzerNames)
            {
                enabled = allOptions.GetProperty(BuildDefaultEnabledProperty(analyzerName));
            }
            return(allOptions);
        }
示例#11
0
        /// <summary>
        /// Selects a character to play with.
        /// </summary>
        /// <param name="characterId"></param>
        /// <returns></returns>
        public bool SelectCharacter(int characterId)
        {
            PropertyBag bag = new PropertyBag();

            bag.SetProperty((int)PropertyID.CharacterId, characterId);
            SendGenericMessage((int)GenericMessageType.RequestSelectCharacter, bag, false);
            return(true);
        }
示例#12
0
        private void SaveComics(ArrayList aComics, string fileName)
        {
            PropertyBag bags;

            bags = new PropertyBag();

            foreach (ComicInfo ci in aComics)
            {
                PropertyBag comicBag;

                comicBag      = new PropertyBag();
                comicBag.Name = ci.DisplayName;
                comicBag.SetProperty("Website", ci.Website);
                comicBag.SetProperty("FolderName", ci.FolderName);
                comicBag.SetProperty("DisplayName", ci.DisplayName);
                comicBag.SetProperty("ImageSuffix", ci.ImageSuffix);
                comicBag.SetProperty("ImageFilename", ci.ImageFilename);
                comicBag.SetProperty("ImagePath", ci.ImagePath);
                comicBag.SetProperty("Subscribed", ci.Subscribed.ToString());

                bags.AddBag(comicBag);
            }

            bags.Save(fileName);
            return;
        }
示例#13
0
        /// <summary>
        /// Sends the patch server the version we currently think we are, based on what's in the ver.txt file.
        /// Patch server will send us the next patch in the sequence.
        /// </summary>
        private static void RequestVersionUpdate()
        {
            Log.LogMsg("Requesting version update.");
            AddMsg("Requesting version update.");
            PropertyBag parms = new PropertyBag();

            parms.SetProperty("CurrentVersion", 1, GetCurrentVersion());
            m_PatchCon.SendGenericMessage((byte)GenericMessageType.GetLatestVersion, parms, false);
        }
示例#14
0
 public ExplicitThisAnalyzerTests()
 {
     OptionsHelper.GetPropertiesImplementation = (analyzerOptions) =>
     {
         PropertyBag properties = CreatePolicyThatDisablesAllAnalysis();
         properties.SetProperty(OptionsHelper.BuildDefaultEnabledProperty(ExplicitThisAnalyzer.AnalyzerName), true);
         return(properties);
     };
 }
示例#15
0
 public PlaceImportsOutsideNamespaceTests()
 {
     OptionsHelper.GetPropertiesImplementation = (analyzerOptions) =>
     {
         PropertyBag properties = CreatePolicyThatDisablesAllAnalysis();
         properties.SetProperty(OptionsHelper.BuildDefaultEnabledProperty(PlaceImportsOutsideNamespaceAnalyzer.AnalyzerName), true);
         return(properties);
     };
 }
示例#16
0
        protected PropertyBag CreatePolicyThatDisablesAllAnalysis()
        {
            PropertyBag propertyBag = OptionsHelper.BuildDefaultPropertyBag();

            foreach (string analyzerName in OptionsHelper.AllAnalyzerNames)
            {
                propertyBag.SetProperty(OptionsHelper.BuildDefaultEnabledProperty(analyzerName), false);
            }
            return(propertyBag);
        }
示例#17
0
        /// <summary>
        /// Request the joining of an existing game instance on the game server.
        /// This is a non-blocking call.  Once the game join request has been resolved
        /// the LobbyClient.GameJoinRequestResolved event will fire.
        /// </summary>
        /// <param name="gameId">the ID of the game we wish to join</param>
        /// <param name="msg">a string which will hold player facing text message if the call fails (returns false)</param>
        /// <returns>true if IsGameServerConnected and was ReadyForPlay and the request was thus sent</returns>
        public bool RequestJoinGame(Guid gameId, ref string msg, PropertyBag parms)
        {
            msg = "";
            if (!IsCentralServerConnected || !CentralReadyForCommunication)
            {
                msg = "Not ready to communicate with game server.";
                return(false);
            }

            PropertyBag options = new PropertyBag();

            options.SetProperty("IsNewGame", false);
            options.SetProperty((int)PropertyID.GameId, gameId);
            if (parms != null)
            {
                options.UpdateWithValues(parms);
            }
            TargetGameOptions = options;
            Log.LogMsg("Requesting to join game " + gameId.ToString());
            m_CentralServer.SendGenericMessage((int)GenericLobbyMessageType.JoinGame, options, false);
            return(true);
        }
示例#18
0
        /// <summary>
        /// Notifies the server of far along we are in loading the level after the game has started.
        /// No one can take any moves until all clients are loaded in.
        /// </summary>
        /// <param name="percent">the percentage between 0.0f and 100.0f</param>
        public void NotifyPercentLevelLoaded(float percent)
        {
            if (!Client.GameServerReadyForPlay)
            {
                Log.LogMsg("Tried to send PacketGameMessage type [ ClientLevelLoaded ], but game server not ready.");
                return;
            }

            PropertyBag p = new PropertyBag();

            p.SetProperty("PercentLoaded", Math.Max(0f, percent));
            SendGameMessage((int)LobbyGameMessageSubType.ClientLevelLoaded, p);
        }
示例#19
0
        /// <summary>
        /// Request the creation of a new game instance on the game server.  Any pertinent options should be
        /// included in the parameter.  This is a non-blocking call.  Once the game creation request has been resolved
        /// the LobbyClient.GameCreationRequestResolved event will fire.
        /// </summary>
        /// <param name="options">any options required by the server for game creation</param>
        /// <param name="msg">a string which will hold player facing text message if the call fails (returns false)</param>
        /// <returns>true if IsGameServerConnected and was ReadyForPlay and the request was thus sent</returns>
        public bool RequestCreateNewGame(PropertyBag options, ref string msg)
        {
            msg = "";
            if (!IsCentralServerConnected || !CentralReadyForCommunication)
            {
                msg = "Not ready to communicate with game server.";
                return(false);
            }

            Log.LogMsg("Requesting game [" + options.GetStringProperty((int)PropertyID.Name) + "] creation from Central server.");
            options.SetProperty("IsNewGame", true);
            TargetGameOptions = options;
            m_CentralServer.SendGenericMessage((int)GenericLobbyMessageType.CreateGame, options, true); // encrypt it, beccause it could contain a password
            return(true);
        }
示例#20
0
        /// <summary>
        /// Gets called when a player is removed from the game
        /// </summary>
        /// <param name="character"></param>
        protected virtual void OnPlayerRemoved(ServerCharacterInfo toon, string reason, bool playerInitiated)
        {
            toon.SetCurrentGame(null);

            // Update game stats in game listing DB
            DB.Instance.Lobby_UpdateGameForServer(this);

            // Send notification to player that player left, including game state update. Player is no longer part of "AllPlayers"  list at this point, so we
            // have to manually send this notification to them.
            SendGamePropertiesUpdateToPlayer(toon, this.Properties.ID, this.Properties.AllProperties);
            SendMatchChangeNotificationToPlayer(toon, MatchNotificationType.PlayerRemoved, toon, reason, false);

            // Broadcast to all remaining players
            SendMatchChangeNotificationToPlayers(MatchNotificationType.PlayerRemoved, toon, reason, false);
            SendGamePropertiesUpdateToPlayers(this.Properties.ID, this.Properties.AllProperties);

            // Set new game owner if necessary
            if (Owner == toon.ID)
            {
                if (AllPlayers.Count > 0)
                {
                    Owner = AllPlayers[0].ID;
                    BroadcastGameInfoMessage(AllPlayers[0].CharacterName + " is now the owner of this game.", true);
                    PropertyBag props = new PropertyBag();
                    props.SetProperty("NewOwner", Owner);
                    BroadcastGameMessage((int)LobbyGameMessageSubType.NewOwner, props, true, false, false);
                }
            }

            // when a player leaves the game, they go back to Central
            if (CurrentGameState == GameState.Lobby || CurrentGameState == GameState.Started)
            {
                string address  = "";
                int    port     = 0;
                string serverId = "";
                if (!GSLobbyInboundPlayerConnection.GetCentralHandoffAddress(ref address, ref port, ref serverId))
                {
                    toon.OwningAccount.MyConnection.KillConnection("Unable to host player on this server.  No lobby server found to hand off too after leaving game.");
                    return;
                }
                toon.OwningAccount.TransferToServerUnassisted(address, port, Guid.Empty, "Lobby Server", serverId);
            }
        }
示例#21
0
        public void PropertyBagRepresentsPropertiesCorrectly()
        {
            var propertyBag = new PropertyBag();

            Assert.False(propertyBag.HasProperty("Test"));
            Assert.Null(propertyBag.GetProperty("Test"));
            Assert.Null(propertyBag.GetProperty <string>("Test"));
            Assert.Equal(default(int), propertyBag.GetProperty <int>("Test"));

            propertyBag.SetProperty("Test", "Test");
            Assert.True(propertyBag.HasProperty("Test"));
            Assert.Equal("Test", propertyBag.GetProperty("Test"));
            Assert.Equal("Test", propertyBag.GetProperty <string>("Test"));

            propertyBag.ClearProperty("Test");
            Assert.False(propertyBag.HasProperty("Test"));
            Assert.Null(propertyBag.GetProperty("Test"));
            Assert.Null(propertyBag.GetProperty <string>("Test"));
            Assert.Equal(default(int), propertyBag.GetProperty <int>("Test"));
        }
示例#22
0
        public void PropertyBagRepresentsPropertiesCorrectly()
        {
            var propertyBag = new PropertyBag();

            Assert.False(propertyBag.HasProperty("Test"));
            Assert.Null(propertyBag.GetProperty("Test"));
            Assert.Null(propertyBag.GetProperty<string>("Test"));
            Assert.Equal(default(int), propertyBag.GetProperty<int>("Test"));

            propertyBag.SetProperty("Test", "Test");
            Assert.True(propertyBag.HasProperty("Test"));
            Assert.Equal("Test", propertyBag.GetProperty("Test"));
            Assert.Equal("Test", propertyBag.GetProperty<string>("Test"));

            propertyBag.ClearProperty("Test");
            Assert.False(propertyBag.HasProperty("Test"));
            Assert.Null(propertyBag.GetProperty("Test"));
            Assert.Null(propertyBag.GetProperty<string>("Test"));
            Assert.Equal(default(int), propertyBag.GetProperty<int>("Test"));
        }
示例#23
0
        public override int Run(ExportOptions exportOptions)
        {
            int         result     = FAILED;
            PropertyBag allOptions = new PropertyBag();

            // The export command could be updated in the future to accept an arbitrary set
            // of analyzers for which to build an options XML file suitable for configuring them.
            // Currently, we perform discovery against the built-in CodeFormatter rules
            // and analyzers only.
            foreach (IOptionsProvider provider in GetOptionsProviders(s_defaultCompositionAssemblies))
            {
                foreach (IOption option in provider.GetOptions())
                {
                    allOptions.SetProperty(option, option.DefaultValue);
                }
            }
            allOptions.SaveTo(exportOptions.OutputPath, id: "binskim-policy");
            Console.WriteLine("Options file saved to: " + Path.GetFullPath(exportOptions.OutputPath));

            result = SUCCEEDED;

            return(result);
        }
示例#24
0
        private void RequestClientSpec()
        {
            PropertyBag          bag = new PropertyBag();
            PacketGenericMessage p   = (PacketGenericMessage)CreatePacket((int)PacketType.PacketGenericMessage, 878787, false, false);

            p.Parms            = bag;
            p.NeedsDeliveryAck = false;

            if (PatchServerProcess.Instance.CaptureCPU)
            {
                bag.SetProperty("cpu", true);
            }

            if (PatchServerProcess.Instance.CaptureDrives)
            {
                bag.SetProperty("drives", true);
            }

            if (PatchServerProcess.Instance.CaptureGPU)
            {
                bag.SetProperty("gpu", true);
            }

            if (PatchServerProcess.Instance.CaptureMainboard)
            {
                bag.SetProperty("mainboard", true);
            }

            if (PatchServerProcess.Instance.CaptureOS)
            {
                bag.SetProperty("os", true);
            }

            if (PatchServerProcess.Instance.CaptureRAM)
            {
                bag.SetProperty("ram", true);
            }

            Send(p);
        }
示例#25
0
        private void RequestClientSpec()
        {
            PropertyBag bag = new PropertyBag();
            PacketGenericMessage p = (PacketGenericMessage)CreatePacket((int)PacketType.PacketGenericMessage, 878787, false, false);
            p.Parms = bag;
            p.NeedsDeliveryAck = false;

            if (PatchServerProcess.Instance.CaptureCPU)
            {
                bag.SetProperty("cpu", true);
            }

            if (PatchServerProcess.Instance.CaptureDrives)
            {
                bag.SetProperty("drives", true);
            }

            if (PatchServerProcess.Instance.CaptureGPU)
            {
                bag.SetProperty("gpu", true);
            }

            if (PatchServerProcess.Instance.CaptureMainboard)
            {
                bag.SetProperty("mainboard", true);
            }

            if (PatchServerProcess.Instance.CaptureOS)
            {
                bag.SetProperty("os", true);
            }

            if (PatchServerProcess.Instance.CaptureRAM)
            {
                bag.SetProperty("ram", true);
            }

            Send(p);
        }
示例#26
0
        public void OnGetLatestVersion(INetworkConnection con, Packet nmsg)
        {
            PacketGenericMessage packet = nmsg as PacketGenericMessage;
            string version = packet.Parms.GetStringProperty("CurrentVersion");

            try
            {
                double curVersion = double.Parse(version);
                int idx = PatchServerProcess.Patches.IndexOfKey(curVersion);
                if (idx == -1)
                {
                    Log1.Logger("Server").Info("User reported being at version number [" + version + "]. Version not known as per Versions.txt. Dropping user connection.");
                    KillConnection("Unknown current version.");
                    return;
                }

                if (!m_SentPatchNotes)
                {
                    PropertyBag bag = new PropertyBag();
                    bag.SetProperty("notes", 1, PatchServerProcess.PatchNotes);
                    PacketGenericMessage p = (PacketGenericMessage)CreatePacket((int)PacketType.PacketGenericMessage, (int)GenericMessageType.Notes, false, false);
                    p.Parms = bag;
                    p.NeedsDeliveryAck = true;
                    Send(p);
                    m_SentPatchNotes = true;
                }

                if (idx == (PatchServerProcess.Patches.Count - 1))
                {
                    // if the server is configured to collect client spec data, then we do it right before we tell the client they're current.
                    // if not, just send the iscurrent message now.
                    if (ShouldCollectClientSpecs())
                    {
                        RequestClientSpec();
                    }
                    else
                    {
                        SendVersionIsCurrent();
                    }
                    return;
                }

                // get next patch in line
                idx++;
                FileInfo fi = PatchServerProcess.Patches.Values[idx];
                try
                {
                    double newVersion = PatchServerProcess.Patches.Keys[idx];
                    SendFileStream(fi, newVersion.ToString());
                }
                catch(Exception se)
                {
                    Log1.Logger("Patcher").Error("Error sending patch to " + RemoteEndPoint.ToString(), se);
                }
            }
            catch(Exception e)
            {
                KillConnection("Malformed patch request. " + e.Message);
                return;
            }

            // we only send one patch file.  let client process that file, then call us back for next file.
            if (Transit.NumAcksWaitingFor < 1)
            {
                KillConnection("Patch sent.");
            }
            else
            {
                SetTimer(500);
            }
        }
示例#27
0
        /// <summary>
        /// Request the creation of a new game instance on the game server.  Any pertinent options should be
        /// included in the parameter.  This is a non-blocking call.  Once the game creation request has been resolved
        /// the LobbyClient.GameCreationRequestResolved event will fire.
        /// </summary>
        /// <param name="options">any options required by the server for game creation</param>
        /// <param name="msg">a string which will hold player facing text message if the call fails (returns false)</param>
        /// <returns>true if IsGameServerConnected and was ReadyForPlay and the request was thus sent</returns>
        public bool RequestCreateNewGame(PropertyBag options, ref string msg)
        {
            msg = "";
            if (!IsCentralServerConnected || !CentralReadyForCommunication)
            {
                msg = "Not ready to communicate with game server.";
                return false;
            }

            Log.LogMsg("Requesting game [" + options.GetStringProperty((int)PropertyID.Name) + "] creation from Central server.");
            options.SetProperty("IsNewGame", true);
            TargetGameOptions = options;
            m_CentralServer.SendGenericMessage((int)GenericLobbyMessageType.CreateGame, options, true); // encrypt it, beccause it could contain a password
            return true;
        }
示例#28
0
        private void SaveComics( ArrayList aComics, string fileName )
        {
            PropertyBag bags;

            bags = new PropertyBag();

            foreach( ComicInfo ci in aComics )
            {
                PropertyBag comicBag;

                comicBag = new PropertyBag();
                comicBag.Name = ci.DisplayName;
                comicBag.SetProperty( "Website", ci.Website );
                comicBag.SetProperty( "FolderName", ci.FolderName );
                comicBag.SetProperty( "DisplayName", ci.DisplayName );
                comicBag.SetProperty( "ImageSuffix", ci.ImageSuffix );
                comicBag.SetProperty( "ImageFilename", ci.ImageFilename );
                comicBag.SetProperty( "ImagePath", ci.ImagePath );
                comicBag.SetProperty( "Subscribed", ci.Subscribed.ToString() );

                bags.AddBag( comicBag );
            }

            bags.Save( fileName );
            return;
        }
示例#29
0
        /// <summary>
        /// Reads the character.xml file and returns a list of properties that that character should have
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static bool Character_GetPropertyTypesFromTemplate(string filePath, ref PropertyBag props, ref StatBag stats)
        {
            XPathDocument  doc = LoadDocument(filePath, true);
            XPathNavigator nav = null;

            string[] sections = new string[] { "StringProperties", "IntProperties", "LongProperties", "FloatProperties" };
            try
            {
                if (doc == null)
                {
                    return(false);
                }

                nav = doc.CreateNavigator();
                for (int i = 0; i < sections.Length; i++)
                {
                    XPathNodeIterator iter = nav.Select(@"./Template/Character/PropertyBag/" + sections[i] + "/Property");
                    while (iter.MoveNext())
                    {
                        string id = iter.Current.GetAttribute("ID", "");
                        if (id == null || id.Length < 1)
                        {
                            Log.LogMsg("Error reading ID attribute in node " + iter.Current.InnerXml);
                            continue;
                        }

                        string name = iter.Current.GetAttribute("Name", "");
                        if (name == null)
                        {
                            name = "";
                        }

                        int propertyTypeID = int.Parse(id);

                        if (sections[i] == "IntProperties")
                        {
                            int value = int.Parse(iter.Current.Value);
                            props.SetProperty(name, propertyTypeID, value);
                        }
                        else if (sections[i] == "StringProperties")
                        {
                            props.SetProperty(name, propertyTypeID, iter.Current.Value);
                        }
                        else if (sections[i] == "FloatProperties")
                        {
                            float value = float.Parse(iter.Current.Value);
                            props.SetProperty(name, propertyTypeID, value);
                        }
                        else if (sections[i] == "LongProperties")
                        {
                            long value = long.Parse(iter.Current.Value);
                            props.SetProperty(name, propertyTypeID, value);
                        }
                    }
                }

                // Stats
                XPathNodeIterator statIter = nav.Select(@"./Template/Character/StatBag/Stat");
                while (statIter.MoveNext())
                {
                    int id = int.Parse(statIter.Current.GetAttribute("StatID", ""));

                    Stat proto = StatManager.Instance[id];
                    if (proto == null)
                    {
                        Log.LogMsg("Error reading character template. Stat id [" + id + "] was specified but was not loaded from the Stats.xml configuration file. Stat not added to character.");
                        continue;
                    }

                    float currentValue = float.Parse(statIter.Current.Value);
                    Stat  s            = new Stat(id, proto.DisplayName, proto.Description, proto.Group, currentValue, proto.MinValue, proto.MaxValue);
                    stats.AddStat(s);
                }
            }
            catch (Exception e)
            {
                Log.LogMsg("Failed to load character properties from template.");
                //Log.LogMsg("Exception thrown reading Character template. " + e.Message);
                return(false);
            }

            return(true);
        }
示例#30
0
        /// <summary>
        /// Request a list of all games that the server knows about. This is a non-blocking call. Once the game data arrives, LobbyClient.Games 
        /// will have the latest data in it and LobbyClient.CompleteMatchListingArrived event will fire.
        /// </summary>
        /// <param name="msg">a string which will hold player facing text message if the call fails (returns false)</param>
        /// <returns>true if IsGameServerConnected and was ReadyForPlay and the request was thus sent</returns>
        public bool RequestGameListing(ref string msg, int page, int numPerPage, bool includeInProgress, int minPlayersAllowed, PropertyBag parms)
        {
            msg = "";
            if (!IsCentralServerConnected || !CentralReadyForCommunication)
            {
                msg = "Not ready to communicate with game server.";
                return false;
            }

            Log.LogMsg("Requesting content listing from game server.");
            PropertyBag bag = new PropertyBag();
            bag.SetProperty("Page", page);
            bag.SetProperty("NumPerPage", numPerPage);
            bag.SetProperty("IncludeInProgress", includeInProgress);
            bag.SetProperty("MinPlayersAllowed", minPlayersAllowed);

            // ad-hoc parms
            bag.UpdateWithValues(parms);

            if (GameRequestSearchInvoker != null)
            {
                PropertyBag add = FireGameRequestSearch();
                if (add != null)
                {
                    bag.UpdateWithValues(add);
                }
            }

            m_CentralServer.SendGenericMessage((int)GenericLobbyMessageType.RequestGameListing, bag, false);
            return true;
        }
示例#31
0
        /// <summary>
        /// Request the joining of an existing game instance on the game server.  
        /// This is a non-blocking call.  Once the game join request has been resolved
        /// the LobbyClient.GameJoinRequestResolved event will fire.
        /// </summary>
        /// <param name="gameId">the ID of the game we wish to join</param>
        /// <param name="msg">a string which will hold player facing text message if the call fails (returns false)</param>
        /// <returns>true if IsGameServerConnected and was ReadyForPlay and the request was thus sent</returns>
        public bool RequestJoinGame(Guid gameId, ref string msg, PropertyBag parms)
        {
            msg = "";
            if (!IsCentralServerConnected || !CentralReadyForCommunication)
            {
                msg = "Not ready to communicate with game server.";
                return false;
            }

            PropertyBag options = new PropertyBag();
            options.SetProperty("IsNewGame", false);
            options.SetProperty((int)PropertyID.GameId, gameId);
            if (parms != null)
            {
                options.UpdateWithValues(parms);
            }
            TargetGameOptions = options;
            Log.LogMsg("Requesting to join game " + gameId.ToString());
            m_CentralServer.SendGenericMessage((int)GenericLobbyMessageType.JoinGame, options, false);
            return true;
        }
 /// <summary>
 /// Selects a character to play with.  
 /// </summary>
 /// <param name="characterId"></param>
 /// <returns></returns>
 public bool SelectCharacter(int characterId)
 {
     PropertyBag bag = new PropertyBag();
     bag.SetProperty((int)PropertyID.CharacterId, characterId);
     SendGenericMessage((int)GenericMessageType.RequestSelectCharacter, bag, false);
     return true;
 }
示例#33
0
        public void OnGetLatestVersion(INetworkConnection con, Packet nmsg)
        {
            PacketGenericMessage packet = nmsg as PacketGenericMessage;
            string version = packet.Parms.GetStringProperty("CurrentVersion");

            try
            {
                double curVersion = double.Parse(version);
                int    idx        = PatchServerProcess.Patches.IndexOfKey(curVersion);
                if (idx == -1)
                {
                    Log1.Logger("Server").Info("User reported being at version number [" + version + "]. Version not known as per Versions.txt. Dropping user connection.");
                    KillConnection("Unknown current version.");
                    return;
                }

                if (!m_SentPatchNotes)
                {
                    PropertyBag bag = new PropertyBag();
                    bag.SetProperty("notes", 1, PatchServerProcess.PatchNotes);
                    PacketGenericMessage p = (PacketGenericMessage)CreatePacket((int)PacketType.PacketGenericMessage, (int)GenericMessageType.Notes, false, false);
                    p.Parms            = bag;
                    p.NeedsDeliveryAck = true;
                    Send(p);
                    m_SentPatchNotes = true;
                }

                if (idx == (PatchServerProcess.Patches.Count - 1))
                {
                    // if the server is configured to collect client spec data, then we do it right before we tell the client they're current.
                    // if not, just send the iscurrent message now.
                    if (ShouldCollectClientSpecs())
                    {
                        RequestClientSpec();
                    }
                    else
                    {
                        SendVersionIsCurrent();
                    }
                    return;
                }

                // get next patch in line
                idx++;
                FileInfo fi = PatchServerProcess.Patches.Values[idx];
                try
                {
                    double newVersion = PatchServerProcess.Patches.Keys[idx];
                    SendFileStream(fi, newVersion.ToString());
                }
                catch (Exception se)
                {
                    Log1.Logger("Patcher").Error("Error sending patch to " + RemoteEndPoint.ToString(), se);
                }
            }
            catch (Exception e)
            {
                KillConnection("Malformed patch request. " + e.Message);
                return;
            }

            // we only send one patch file.  let client process that file, then call us back for next file.
            if (Transit.NumAcksWaitingFor < 1)
            {
                KillConnection("Patch sent.");
            }
            else
            {
                SetTimer(500);
            }
        }
示例#34
0
        /// <summary>
        /// Notifies the server of far along we are in loading the level after the game has started.
        /// No one can take any moves until all clients are loaded in.
        /// </summary>
        /// <param name="percent">the percentage between 0.0f and 100.0f</param>
        public void NotifyPercentLevelLoaded(float percent)
        {
            if (!Client.GameServerReadyForPlay)
            {
                Log.LogMsg("Tried to send PacketGameMessage type [ ClientLevelLoaded ], but game server not ready.");
                return;
            }

            PropertyBag p = new PropertyBag();
            p.SetProperty("PercentLoaded", Math.Max(0f, percent));
            SendGameMessage((int)LobbyGameMessageSubType.ClientLevelLoaded, p);
        }
示例#35
0
        /// <summary>
        /// Reads the character.xml file and returns a list of properties that that character should have
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static bool Character_GetPropertyTypesFromTemplate(string filePath, ref PropertyBag props, ref StatBag stats)
        {
            XPathDocument doc = LoadDocument(filePath, true);
            XPathNavigator nav = null;

            string[] sections = new string[] { "StringProperties", "IntProperties", "LongProperties", "FloatProperties" };
            try
            {
                if (doc == null)
                {
                    return false;
                }

                nav = doc.CreateNavigator();
                for (int i = 0; i < sections.Length; i++)
                {
                    XPathNodeIterator iter = nav.Select(@"./Template/Character/PropertyBag/" + sections[i] + "/Property");
                    while (iter.MoveNext())
                    {
                        string id = iter.Current.GetAttribute("ID", "");
                        if (id == null || id.Length < 1)
                        {
                            Log.LogMsg("Error reading ID attribute in node " + iter.Current.InnerXml);
                            continue;
                        }

                        string name = iter.Current.GetAttribute("Name", "");
                        if (name == null)
                        {
                            name = "";
                        }

                        int propertyTypeID = int.Parse(id);

                        if (sections[i] == "IntProperties")
                        {
                            int value = int.Parse(iter.Current.Value);
                            props.SetProperty(name, propertyTypeID, value);
                        }
                        else if (sections[i] == "StringProperties")
                        {
                            props.SetProperty(name, propertyTypeID, iter.Current.Value);
                        }
                        else if (sections[i] == "FloatProperties")
                        {
                            float value = float.Parse(iter.Current.Value);
                            props.SetProperty(name, propertyTypeID, value);
                        }
                        else if (sections[i] == "LongProperties")
                        {
                            long value = long.Parse(iter.Current.Value);
                            props.SetProperty(name, propertyTypeID, value);
                        }
                    }
                }

                // Stats
                XPathNodeIterator statIter = nav.Select(@"./Template/Character/StatBag/Stat");
                while (statIter.MoveNext())
                {
                    int id = int.Parse(statIter.Current.GetAttribute("StatID", ""));

                    Stat proto = StatManager.Instance[id];
                    if (proto == null)
                    {
                        Log.LogMsg("Error reading character template. Stat id [" + id + "] was specified but was not loaded from the Stats.xml configuration file. Stat not added to character.");
                        continue;
                    }

                    float currentValue = float.Parse(statIter.Current.Value);
                    Stat s = new Stat(id, proto.DisplayName, proto.Description, proto.Group, currentValue,proto.MinValue, proto.MaxValue);
                    stats.AddStat(s);
                }
            }
            catch (Exception e)
            {
                Log.LogMsg("Failed to load character properties from template.");
                //Log.LogMsg("Exception thrown reading Character template. " + e.Message);
                return false;
            }

            return true;
        }
示例#36
0
文件: Patcher.cs 项目: kamilion/WISP
 /// <summary>
 /// Sends the patch server the version we currently think we are, based on what's in the ver.txt file.
 /// Patch server will send us the next patch in the sequence.
 /// </summary>
 private static void RequestVersionUpdate()
 {
     Log.LogMsg("Requesting version update.");
     AddMsg("Requesting version update.");
     PropertyBag parms = new PropertyBag();
     parms.SetProperty("CurrentVersion", 1, GetCurrentVersion());
     m_PatchCon.SendGenericMessage((byte)GenericMessageType.GetLatestVersion, parms, false);
 }