appsetting util add

main
syneffort 2 years ago
parent f372f00c47
commit 6c52d1172a
  1. 18
      SocketStudy/ClientForm/App.config
  2. 180
      SocketStudy/ClientForm/MainForm.Designer.cs
  3. 41
      SocketStudy/ClientForm/MainForm.cs
  4. 77
      SocketStudy/ClientForm/Properties/Settings.Designer.cs
  5. 20
      SocketStudy/ClientForm/Properties/Settings.settings
  6. 91
      SocketStudy/PUtil/AppSetting.cs
  7. 2
      SocketStudy/PUtil/PUtility.csproj
  8. 15
      SocketStudy/ServerForm/App.config
  9. 11
      SocketStudy/ServerForm/MainForm.cs
  10. 65
      SocketStudy/ServerForm/Properties/Settings.Designer.cs
  11. 17
      SocketStudy/ServerForm/Properties/Settings.settings

@ -1,6 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ClientForm.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" />
</startup>
<userSettings>
<ClientForm.Properties.Settings>
<setting name="SERVER_IP" serializeAs="String">
<value>127.0.0.1</value>
</setting>
<setting name="PORT" serializeAs="String">
<value>37777</value>
</setting>
<setting name="HB_PORT" serializeAs="String">
<value>37779</value>
</setting>
</ClientForm.Properties.Settings>
</userSettings>
</configuration>

@ -32,23 +32,20 @@ namespace ClientForm
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.logConsole = new System.Windows.Forms.TextBox();
this.mainTablePanel = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.panel1 = new System.Windows.Forms.Panel();
this.stringButton = new System.Windows.Forms.Button();
this.fileButton = new System.Windows.Forms.Button();
this.objectButton = new System.Windows.Forms.Button();
this.imageButton = new System.Windows.Forms.Button();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.startButton = new System.Windows.Forms.Button();
this.statusStrip = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.heartBeatStatus = new System.Windows.Forms.ToolStripStatusLabel();
this.addressTextBox = new System.Windows.Forms.TextBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.imageButton = new System.Windows.Forms.Button();
this.objectButton = new System.Windows.Forms.Button();
this.fileButton = new System.Windows.Forms.Button();
this.stringButton = new System.Windows.Forms.Button();
this.startButton = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.mainTablePanel.SuspendLayout();
this.statusStrip.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.panel1.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
//
// logConsole
@ -61,7 +58,7 @@ namespace ClientForm
this.logConsole.Multiline = true;
this.logConsole.Name = "logConsole";
this.logConsole.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.logConsole.Size = new System.Drawing.Size(578, 393);
this.logConsole.Size = new System.Drawing.Size(606, 350);
this.logConsole.TabIndex = 1;
//
// mainTablePanel
@ -76,47 +73,68 @@ namespace ClientForm
this.mainTablePanel.RowCount = 2;
this.mainTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 60F));
this.mainTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.mainTablePanel.Size = new System.Drawing.Size(584, 461);
this.mainTablePanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.mainTablePanel.Size = new System.Drawing.Size(612, 418);
this.mainTablePanel.TabIndex = 3;
//
// statusStrip
//
this.statusStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1,
this.heartBeatStatus});
this.statusStrip.Location = new System.Drawing.Point(0, 396);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(612, 22);
this.statusStrip.TabIndex = 4;
this.statusStrip.Text = "statusStrip1";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 17);
//
// heartBeatStatus
//
this.heartBeatStatus.Name = "heartBeatStatus";
this.heartBeatStatus.Size = new System.Drawing.Size(0, 17);
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 200F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.Controls.Add(this.startButton, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.panel1, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(584, 60);
this.tableLayoutPanel1.Size = new System.Drawing.Size(612, 60);
this.tableLayoutPanel1.TabIndex = 2;
//
// panel1
// imageButton
//
this.panel1.Controls.Add(this.stringButton);
this.panel1.Controls.Add(this.fileButton);
this.panel1.Controls.Add(this.objectButton);
this.panel1.Controls.Add(this.imageButton);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(203, 3);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(378, 54);
this.panel1.TabIndex = 4;
this.imageButton.Location = new System.Drawing.Point(191, 15);
this.imageButton.Name = "imageButton";
this.imageButton.Size = new System.Drawing.Size(75, 23);
this.imageButton.TabIndex = 2;
this.imageButton.Text = "image";
this.imageButton.UseVisualStyleBackColor = true;
this.imageButton.Click += new System.EventHandler(this.imageButton_Click);
//
// stringButton
// objectButton
//
this.stringButton.Location = new System.Drawing.Point(29, 15);
this.stringButton.Name = "stringButton";
this.stringButton.Size = new System.Drawing.Size(75, 23);
this.stringButton.TabIndex = 2;
this.stringButton.Text = "string";
this.stringButton.UseVisualStyleBackColor = true;
this.stringButton.Click += new System.EventHandler(this.stringButton_Click);
this.objectButton.Location = new System.Drawing.Point(110, 15);
this.objectButton.Name = "objectButton";
this.objectButton.Size = new System.Drawing.Size(75, 23);
this.objectButton.TabIndex = 2;
this.objectButton.Text = "object";
this.objectButton.UseVisualStyleBackColor = true;
this.objectButton.Click += new System.EventHandler(this.objectButton_Click);
//
// fileButton
//
@ -128,88 +146,44 @@ namespace ClientForm
this.fileButton.UseVisualStyleBackColor = true;
this.fileButton.Click += new System.EventHandler(this.fileButton_Click);
//
// objectButton
//
this.objectButton.Location = new System.Drawing.Point(110, 15);
this.objectButton.Name = "objectButton";
this.objectButton.Size = new System.Drawing.Size(75, 23);
this.objectButton.TabIndex = 2;
this.objectButton.Text = "object";
this.objectButton.UseVisualStyleBackColor = true;
this.objectButton.Click += new System.EventHandler(this.objectButton_Click);
//
// imageButton
//
this.imageButton.Location = new System.Drawing.Point(191, 15);
this.imageButton.Name = "imageButton";
this.imageButton.Size = new System.Drawing.Size(75, 23);
this.imageButton.TabIndex = 2;
this.imageButton.Text = "image";
this.imageButton.UseVisualStyleBackColor = true;
this.imageButton.Click += new System.EventHandler(this.imageButton_Click);
// stringButton
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.ColumnCount = 1;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.Controls.Add(this.startButton, 0, 1);
this.tableLayoutPanel2.Controls.Add(this.addressTextBox, 0, 0);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 2;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(194, 54);
this.tableLayoutPanel2.TabIndex = 5;
this.stringButton.Location = new System.Drawing.Point(29, 15);
this.stringButton.Name = "stringButton";
this.stringButton.Size = new System.Drawing.Size(75, 23);
this.stringButton.TabIndex = 2;
this.stringButton.Text = "string";
this.stringButton.UseVisualStyleBackColor = true;
this.stringButton.Click += new System.EventHandler(this.stringButton_Click);
//
// startButton
//
this.startButton.Dock = System.Windows.Forms.DockStyle.Fill;
this.startButton.Location = new System.Drawing.Point(3, 30);
this.startButton.Location = new System.Drawing.Point(3, 3);
this.startButton.Name = "startButton";
this.startButton.Size = new System.Drawing.Size(188, 21);
this.startButton.Size = new System.Drawing.Size(194, 54);
this.startButton.TabIndex = 0;
this.startButton.Text = "Connect";
this.startButton.UseVisualStyleBackColor = true;
this.startButton.Click += new System.EventHandler(this.startButton_Click);
//
// statusStrip
//
this.statusStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1,
this.heartBeatStatus});
this.statusStrip.Location = new System.Drawing.Point(0, 439);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(584, 22);
this.statusStrip.TabIndex = 4;
this.statusStrip.Text = "statusStrip1";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 17);
//
// heartBeatStatus
//
this.heartBeatStatus.Name = "heartBeatStatus";
this.heartBeatStatus.Size = new System.Drawing.Size(0, 17);
//
// addressTextBox
// panel1
//
this.addressTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.addressTextBox.Location = new System.Drawing.Point(3, 3);
this.addressTextBox.Name = "addressTextBox";
this.addressTextBox.Size = new System.Drawing.Size(188, 21);
this.addressTextBox.TabIndex = 1;
this.addressTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.panel1.Controls.Add(this.stringButton);
this.panel1.Controls.Add(this.fileButton);
this.panel1.Controls.Add(this.objectButton);
this.panel1.Controls.Add(this.imageButton);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(203, 3);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(406, 54);
this.panel1.TabIndex = 4;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(584, 461);
this.ClientSize = new System.Drawing.Size(612, 418);
this.Controls.Add(this.statusStrip);
this.Controls.Add(this.mainTablePanel);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@ -217,12 +191,10 @@ namespace ClientForm
this.Text = "Client";
this.mainTablePanel.ResumeLayout(false);
this.mainTablePanel.PerformLayout();
this.tableLayoutPanel1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel2.PerformLayout();
this.statusStrip.ResumeLayout(false);
this.statusStrip.PerformLayout();
this.tableLayoutPanel1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -236,14 +208,12 @@ namespace ClientForm
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.ToolStripStatusLabel heartBeatStatus;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Button startButton;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button stringButton;
private System.Windows.Forms.Button fileButton;
private System.Windows.Forms.Button objectButton;
private System.Windows.Forms.Button imageButton;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.Button startButton;
private System.Windows.Forms.TextBox addressTextBox;
}
}

@ -21,8 +21,9 @@ namespace ClientForm
public partial class MainForm : Form
{
private readonly int PORT = 37777;
private readonly int HB_PORT = 37778;
private string serverIP = "127.0.0.1";
private int serverPort = 37777;
private int heartBeatPort = 37778;
private PClient heartBeatClient;
private PClient client;
@ -36,6 +37,15 @@ namespace ClientForm
public MainForm()
{
InitializeComponent();
InitInstance();
}
private void InitInstance()
{
//AppSetting.Default.SetValue<string>("SERVER_IP", "127.0.0.105");
serverIP = AppSetting.Default.GetValue<string>("SERVER_IP", "127.0.0.1");
serverPort = AppSetting.Default.GetValue<int>("PORT", 37777);
heartBeatPort = AppSetting.Default.GetValue<int>("HB_PORT", 37778);
}
private void ConnectToServer(string address)
@ -50,14 +60,14 @@ namespace ClientForm
logHandler = new LogHandler(WriteLog);
formHandler = new FormHandler(ShowForm);
heartBeatClient = new PClient(ipAddress, HB_PORT, heartBeatClientId);
heartBeatClient = new PClient(ipAddress, heartBeatPort, heartBeatClientId);
heartBeatClient.OnConnected += CommonClient_OnConnected;
heartBeatClient.OnSend += HeartBeatClient_OnSend;
heartBeatClient.OnReceived += HeartBeatClient_OnReceived;
heartBeatClient.OnErrorCatched += CommonClient_OnErrorCatched;
heartBeatClient.OnDisconnected += CommonClient_OnDisconnected;
client = new PClient(ipAddress, PORT, clientId);
client = new PClient(ipAddress, serverPort, clientId);
client.OnConnected += CommonClient_OnConnected;
client.OnSend += Client_OnSend;
client.OnReceived += Client_OnReceived;
@ -248,27 +258,14 @@ namespace ClientForm
private void startButton_Click(object sender, EventArgs e)
{
if (startButton.Text == "Connect")
if (string.IsNullOrEmpty(serverIP))
{
startButton.Text = "Disconnect";
string address = addressTextBox.Text;
if (string.IsNullOrEmpty(address))
{
MessageBox.Show("Empty address");
return;
}
ConnectToServer(address);
addressTextBox.Enabled = false;
MessageBox.Show("Empty address");
return;
}
else
{
startButton.Text = "Connect";
DisconnectFromServer();
addressTextBox.Enabled = true;
}
ConnectToServer(serverIP);
startButton.Enabled = false;
}
}
}

@ -1,29 +1,62 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// 이 코드는 도구를 사용하여 생성되었습니다.
// 런타임 버전:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
// 이러한 변경 내용이 손실됩니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ClientForm.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
namespace ClientForm.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("127.0.0.1")]
public string SERVER_IP {
get {
return ((string)(this["SERVER_IP"]));
}
set {
this["SERVER_IP"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("37777")]
public string PORT {
get {
return ((string)(this["PORT"]));
}
set {
this["PORT"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("37779")]
public string HB_PORT {
get {
return ((string)(this["HB_PORT"]));
}
set {
this["HB_PORT"] = value;
}
}
}
}

@ -1,7 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ClientForm.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="SERVER_IP" Type="System.String" Scope="User">
<Value Profile="(Default)">127.0.0.1</Value>
</Setting>
<Setting Name="PORT" Type="System.String" Scope="User">
<Value Profile="(Default)">37777</Value>
</Setting>
<Setting Name="HB_PORT" Type="System.String" Scope="User">
<Value Profile="(Default)">37779</Value>
</Setting>
</Settings>
</SettingsFile>

@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PUtility
{
public class AppSetting
{
public static AppSetting Default { get; set; } = new AppSetting();
public string ConfigFileName { get; private set; }
private Configuration configuration;
public Configuration Config
{
get
{
if (configuration == null)
{
if (string.IsNullOrEmpty(ConfigFileName))
{
configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
}
else
{
ExeConfigurationFileMap configMap = new ExeConfigurationFileMap();
configMap.ExeConfigFilename = this.ConfigFileName;
configuration = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
}
}
return configuration;
}
}
public AppSetting(string fileName = null)
{
InitInstance(fileName);
}
private void InitInstance(string fileName)
{
this.ConfigFileName = fileName;
}
public void Refresh()
{
configuration = null;
}
public T GetValue<T>(string key, T defaultValue)
{
if (this.Config.AppSettings.Settings[key] == null)
return defaultValue;
string source = this.Config.AppSettings.Settings[key].Value;
TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
try
{
return (T)converter.ConvertFromString(source);
}
catch (Exception ex)
{
PFileManager.Instance.WriteLog($"AppSetting.GetValue Exception: {ex.Message}");
return defaultValue;
}
}
public void SetValue<T>(string key, T value)
{
Refresh();
TypeConverter converter = TypeDescriptor.GetConverter(typeof(T));
string valueString = converter.ConvertToString(value);
if (this.Config.AppSettings.Settings[key] == null)
this.Config.AppSettings.Settings.Add(key, valueString);
else
this.Config.AppSettings.Settings[key].Value = valueString;
this.Config.Save();
if (string.IsNullOrEmpty(ConfigFileName))
ConfigurationManager.RefreshSection("appSettings");
}
}
}

@ -50,6 +50,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
@ -61,6 +62,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppSetting.cs" />
<Compile Include="PFileManager.cs" />
<Compile Include="PUtil.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

@ -1,6 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ServerForm.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" />
</startup>
<userSettings>
<ServerForm.Properties.Settings>
<setting name="PORT" serializeAs="String">
<value>37777</value>
</setting>
<setting name="HB_PORT" serializeAs="String">
<value>37778</value>
</setting>
</ServerForm.Properties.Settings>
</userSettings>
</configuration>

@ -19,8 +19,8 @@ namespace ServerForm
public partial class MainForm : Form
{
private readonly int PORT = 37777;
private readonly int HB_PORT = 37778;
private int serverPort = 37777;
private int heartBeatPort = 37778;
private PServer mainServer;
private PServer heartBeatServer;
@ -39,10 +39,11 @@ namespace ServerForm
private void InitInstance()
{
string path = Application.StartupPath;
serverPort = AppSetting.Default.GetValue<int>("PORT", 37777);
heartBeatPort = AppSetting.Default.GetValue<int>("HB_PORT", 37778);
heartBeatServer = new PServer(HB_PORT);
mainServer = new PServer(PORT);
heartBeatServer = new PServer(heartBeatPort);
mainServer = new PServer(serverPort);
logHandler = new LogHandler(WriteLog);
formHandler = new FormHandler(ShowForm);

@ -1,29 +1,50 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// 이 코드는 도구를 사용하여 생성되었습니다.
// 런타임 버전:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
// 이러한 변경 내용이 손실됩니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ServerForm.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
namespace ServerForm.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("37777")]
public string PORT {
get {
return ((string)(this["PORT"]));
}
set {
this["PORT"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("37778")]
public string HB_PORT {
get {
return ((string)(this["HB_PORT"]));
}
set {
this["HB_PORT"] = value;
}
}
}
}

@ -1,7 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ServerForm.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="PORT" Type="System.String" Scope="User">
<Value Profile="(Default)">37777</Value>
</Setting>
<Setting Name="HB_PORT" Type="System.String" Scope="User">
<Value Profile="(Default)">37778</Value>
</Setting>
</Settings>
</SettingsFile>
Loading…
Cancel
Save