コード例 #1
0
ファイル: ConfigGenerator.cs プロジェクト: TagsRocks/GladNet
        private bool CreateConfigFile(string dllName, string hailMessage, string appName, int port, string fileName)
        {
            if (!dllName.Contains(".dll"))
            {
                dllName += ".dll";
            }

            ConfigInformation info = new ConfigInformation(dllName, hailMessage, appName, port);

            if (fileName.Length == 0)
            {
                return(false);
            }

            using (StreamWriter sw = new StreamWriter(fileName + ".config", false))
            {
                try
                {
                    string xmlString = Serializer <GladNetXmlSerializer> .Instance.SerializeToString(info);

                    sw.Write(xmlString);
                }
                catch (LoggableException e)
                {
                    MessageBox.Show(this, "Encountered Error: " + e.Message +
                                    e.InnerException != null ? e.InnerException.Message : "");
                    return(false);
                }
            }

            MessageBox.Show(Owner, "Config file was successfully created in the root director named: " + fileNameText.Text + ".config",
                            "Creation Result");
            return(true);
        }
コード例 #2
0
ファイル: ServerProcess.cs プロジェクト: TagsRocks/GladNet
        //DLLNAME APPNAME HAILMESSAGE PORT PIPEHANDLE
        public ServerProcess(string path, ConfigInformation info)
        {
            serverBroadcastingPipe =
                new AnonymousPipeServerStream(PipeDirection.Out, System.IO.HandleInheritability.Inheritable);

            serverStreamWriter = new StreamWriter(serverBroadcastingPipe);

            try
            {
                Config = info;
                string clientString = serverBroadcastingPipe.GetClientHandleAsString();

                ApplicationProcess = Process.Start(new ProcessStartInfo()
                {
                    Arguments = Config.DLLName + " " + Config.ApplicationName + " " + Config.HailMessage + " " +
                                Config.Port.ToString() + " " + clientString,
                    UseShellExecute = false,
                    FileName        = path
                });

                UniqueProcessID = ApplicationProcess.Id;

                ApplicationProcess.EnableRaisingEvents = true;

                ApplicationProcess.Exited += new EventHandler(OnExit);
            }
            catch (NullReferenceException e)
            {
                MessageBox.Show(e.Message + " " + e.Data + e.StackTrace);
            }
        }
コード例 #3
0
ファイル: LauncherForm.cs プロジェクト: TagsRocks/GladNet
        private void AddNewConfigToList(ConfigInformation config, string configFileName)
        {
            if (ConfigDictionary.ContainsKey(configFileName))
            {
                MessageBox.Show(this, "You've already loaded this config file.", "Open Result");
            }
            else
            {
                this.ConfigDictionary.Add(configFileName, config);
                this.configList.Clear();

                foreach (var kp in ConfigDictionary)
                {
                    configList.Items.Add(kp.Key);
                }
            }
        }
コード例 #4
0
ファイル: LauncherForm.cs プロジェクト: TagsRocks/GladNet
        private void StartServer(string configKey)
        {
            //Should exist
            ConfigInformation info = this.ConfigDictionary[configKey];

            ServerProcess sProcess = new ServerProcess("ServerLoader.exe", info);

            //Remove the sever process from the process list on exited.
            sProcess.OnExited += () =>
            {
                StopServerProcess(sProcess);
                ServerProcess proc;
                ServerProcesses.TryRemove(sProcess.UniqueProcessID, out proc);
                this.UpdateProcessList();
                sProcess.Dispose();
            };

            this.ServerProcesses.TryAdd(sProcess.UniqueProcessID, sProcess);
            this.UpdateProcessList();
        }