diff --git a/FunGame.Core.Api/Model/Enum/CommonEnums.cs b/FunGame.Core.Api/Model/Enum/CommonEnums.cs
index e85c056..ccc2701 100644
--- a/FunGame.Core.Api/Model/Enum/CommonEnums.cs
+++ b/FunGame.Core.Api/Model/Enum/CommonEnums.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
@@ -8,7 +9,7 @@ namespace FunGame.Core.Api.Model.Enum
{
///
/// 这里存放框架实现相关的State Type Result Method
- /// 添加FunGame.Core.Api接口和实现时,需要在这里同步添加:InterfaceType和InterfaceMethod
+ /// 添加FunGame.Core.Api接口和实现时,需要在这里同步添加:InterfaceType、InterfaceMethod
///
public static class CommonEnums
{
@@ -63,6 +64,23 @@ namespace FunGame.Core.Api.Model.Enum
ServerInterface = 2
}
+ public enum LightType
+ {
+ Green = 1,
+ Yellow = 2,
+ Red = 3
+ }
+
+ public enum SocketType
+ {
+ Unknown = 0,
+ GetNotice = 1,
+ Login = 2,
+ CheckLogin = 3,
+ Logout = 4,
+ HeartBeat = 5
+ }
+
#endregion
#region Result
@@ -96,5 +114,56 @@ namespace FunGame.Core.Api.Model.Enum
#endregion
+ #region 工具方法
+
+ ///
+ /// 获取实现类类名
+ ///
+ /// 接口代号
+ ///
+ public static string GetImplementClassName(int Interface)
+ {
+ foreach (string str in System.Enum.GetNames(typeof(InterfaceType)))
+ {
+ InterfaceType temp = (InterfaceType)System.Enum.Parse(typeof(InterfaceType), Interface.ToString(), true);
+ if (temp.ToString() == str)
+ return temp + "Impl";
+ }
+ return "";
+ }
+
+ ///
+ /// 获取实现类的方法名
+ ///
+ /// 方法代号
+ ///
+ public static string GetImplementMethodName(int Method)
+ {
+ foreach (string str in System.Enum.GetNames(typeof(InterfaceMethod)))
+ {
+ InterfaceMethod temp = (InterfaceMethod)System.Enum.Parse(typeof(InterfaceMethod), Method.ToString(), true);
+ if (temp.ToString() == str)
+ return temp.ToString();
+ }
+ return "";
+ }
+
+ ///
+ /// 获取Socket枚举名
+ ///
+ /// Socket枚举
+ ///
+ public static string GetSocketTypeName(int SocketType)
+ {
+ foreach (string str in System.Enum.GetNames(typeof(SocketType)))
+ {
+ SocketType temp = (SocketType)System.Enum.Parse(typeof(SocketType), SocketType.ToString(), true);
+ if (temp.ToString() == str)
+ return temp.ToString();
+ }
+ return "";
+ }
+
+ #endregion
}
}
diff --git a/FunGame.Core.Api/Model/Enum/FunGameEnums.cs b/FunGame.Core.Api/Model/Enum/FunGameEnums.cs
new file mode 100644
index 0000000..53d3901
--- /dev/null
+++ b/FunGame.Core.Api/Model/Enum/FunGameEnums.cs
@@ -0,0 +1,50 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FunGame.Core.Api.Model.Enum
+{
+ ///
+ /// 鐢ㄤ簬璁板綍鐗堟湰鍙峰拰鏇存柊鏃ュ織
+ ///
+ public static class FunGameEnums
+ {
+ public const string FunGame_Core = "FunGame Core";
+ public const string FunGame_Core_Api = "FunGame Core Api";
+ public const string FunGame_Console = "FunGame Console";
+ public const string FunGame_Desktop = "FunGame Desktop";
+ public const string FunGame_Server = "FunGame Server";
+
+ public const int FirstVersion = 1;
+ public const int SecondVersion = 0;
+ public const int ThirdVersion = 0;
+
+ public enum Patch
+ {
+ Latest = 20221001,
+ Patch20220906 = 20220906
+ }
+
+ public enum History
+ {
+ Latest = 20221001,
+ R20220906 = 20220906
+ }
+
+ public static string GetVersion()
+ {
+ return "=/=\\=/=\\=/=\\=/= > FunGame鐗堟湰淇℃伅 < =\\=/=\\=/=\\=/=\\=" + "\n" +
+ FunGame_Core + " -> v" + FirstVersion + "." + SecondVersion + ((int)Patch.Latest == (int)History.Latest ? " Patch" + (int)Patch.Latest : "") + "\n" +
+ FunGame_Core_Api + " -> v" + FirstVersion + "." + SecondVersion + ((int)Patch.Latest == (int)History.Latest ? " Patch" + (int)Patch.Latest : "") + "\n" +
+ FunGame_Desktop + " -> v" + FirstVersion + "." + SecondVersion + ((int)Patch.Latest == (int)History.Latest ? " Patch" + (int)Patch.Latest : "");
+ }
+
+ /**
+ * 鏇存柊鏃ュ織
+ *
+ *
+ */
+ }
+}
diff --git a/FunGame.Core.Api/Model/Enum/SocketEnums.cs b/FunGame.Core.Api/Model/Enum/SocketEnums.cs
deleted file mode 100644
index f737320..0000000
--- a/FunGame.Core.Api/Model/Enum/SocketEnums.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace FunGame.Core.Api.Model.Enum
-{
- public static class SocketEnums
- {
- public enum Type
- {
- GetNotice = 1,
- Login = 2,
- CheckLogin = 3,
- Logout = 4,
- HeartBeat = 5
- }
-
- public const string TYPE_UNKNOWN = "Unknown Type";
- public const string TYPE_GetNotice = "GetNotice";
- public const string TYPE_Login = "Login";
- public const string TYPE_CheckLogin = "CheckLogin";
- public const string TYPE_Logout = "Logout";
- public const string TYPE_HeartBeat = "HeartBeat";
- }
-}
diff --git a/FunGame.Core.Api/Util/AssemblyHelper.cs b/FunGame.Core.Api/Util/AssemblyHelper.cs
index ff6bcd2..f989ad1 100644
--- a/FunGame.Core.Api/Util/AssemblyHelper.cs
+++ b/FunGame.Core.Api/Util/AssemblyHelper.cs
@@ -12,57 +12,10 @@ namespace FunGame.Core.Api.Util
{
///
/// 鍦‵unGame.Core.Api涓坊鍔犳柊鎺ュ彛鍜屾柊瀹炵幇鏃讹紝闇瑕侊細
- /// 1銆佸湪杩欓噷瀹氫箟绫诲悕鍜屾柟娉曞悕
- /// 2銆佸湪FunGame.Core.Api.Model.Enum.CommonEnums閲屽悓姝ユ坊鍔營nterfaceType鍜孖nterfaceMethod
- /// 3銆佸湪GetClassName(int)銆丟etMethodName(int)涓坊鍔爏witch鍒嗘敮
+ /// 鍦‵unGame.Core.Api.Model.Enum.CommonEnums閲屽悓姝ユ坊鍔營nterfaceType銆両nterfaceMethod
///
public class AssemblyHelper
{
- /**
- * 瀹氫箟绫诲悕
- */
- public const string ClientConnectInterface = "ClientConnectInterface";
- public const string ServerInterface = "ServerInterface";
-
- /**
- * 瀹氫箟鏂规硶鍚
- */
- public const string RemoteServerIP = "RemoteServerIP";
- public const string DBConnection = "DBConnection";
- public const string GetServerSettings = "GetServerSettings";
-
- ///
- /// 鑾峰彇瀹炵幇绫荤被鍚嶏紙xxInterfaceImpl锛
- ///
- /// 鎺ュ彛浠e彿
- ///
- private string GetClassName(int Interface)
- {
- return Interface switch
- {
- (int)CommonEnums.InterfaceType.ClientConnectInterface => ClientConnectInterface + Implement,
- (int)CommonEnums.InterfaceType.ServerInterface => ServerInterface + Implement,
- _ => "",
- };
- }
-
- ///
- /// 鑾峰彇鏂规硶鍚
- ///
- /// 鏂规硶浠e彿
- ///
- private string GetMethodName(int Method)
- {
- // 閫氳繃AssemblyHelperType鏉ヨ幏鍙栨柟娉曞悕
- return Method switch
- {
- (int)CommonEnums.InterfaceMethod.RemoteServerIP => RemoteServerIP,
- (int)CommonEnums.InterfaceMethod.DBConnection => DBConnection,
- (int)CommonEnums.InterfaceMethod.GetServerSettings => GetServerSettings,
- _ => "",
- };
- }
-
/**
* 瀹氫箟闇瑕佸弽灏勭殑DLL
*/
@@ -71,7 +24,6 @@ namespace FunGame.Core.Api.Util
/**
* 鏃犻渶浜屾淇敼鐨
*/
- public const string Implement = "Impl"; // 瀹炵幇绫荤殑鍚庣紑
public static string EXEDocPath = System.Environment.CurrentDirectory.ToString() + "\\"; // 绋嬪簭鐩綍
public static string PluginDocPath = System.Environment.CurrentDirectory.ToString() + "\\plugins\\"; // 鎻掍欢鐩綍
@@ -95,7 +47,7 @@ namespace FunGame.Core.Api.Util
private Type? GetFunGameCoreImplement(int Interface)
{
// 閫氳繃绫诲悕鑾峰彇鑾峰彇鍛藉悕绌洪棿+绫诲悕绉
- string ClassName = GetClassName(Interface);
+ string ClassName = CommonEnums.GetImplementClassName(Interface);
List? Classes = null;
if (Assembly != null)
{
@@ -120,7 +72,7 @@ namespace FunGame.Core.Api.Util
{
Assembly = Assembly.LoadFile(EXEDocPath + @FUNGAME_CORE + ".dll");
Type = GetFunGameCoreImplement(Interface); // 閫氳繃绫诲悕鑾峰彇鑾峰彇鍛藉悕绌洪棿+绫诲悕绉
- string MethodName = GetMethodName(Method); // 鑾峰彇鏂规硶鍚
+ string MethodName = CommonEnums.GetImplementMethodName(Method); // 鑾峰彇鏂规硶鍚
if (Assembly != null && Type != null) this.Method = Type.GetMethod(MethodName); // 浠嶵ype涓煡鎵炬柟娉曞悕
else return null;
Instance = Assembly.CreateInstance(Type.Namespace + "." + Type.Name);
diff --git a/FunGame.Desktop/Images/green.png b/FunGame.Desktop/Images/green.png
index 4f3b032..e88681d 100644
Binary files a/FunGame.Desktop/Images/green.png and b/FunGame.Desktop/Images/green.png differ
diff --git a/FunGame.Desktop/Images/red.png b/FunGame.Desktop/Images/red.png
index 145a85b..1414926 100644
Binary files a/FunGame.Desktop/Images/red.png and b/FunGame.Desktop/Images/red.png differ
diff --git a/FunGame.Desktop/Images/yellow.png b/FunGame.Desktop/Images/yellow.png
new file mode 100644
index 0000000..cab8859
Binary files /dev/null and b/FunGame.Desktop/Images/yellow.png differ
diff --git a/FunGame.Desktop/Models/Config/Config.cs b/FunGame.Desktop/Models/Config/Config.cs
index ccbca07..f14df25 100644
--- a/FunGame.Desktop/Models/Config/Config.cs
+++ b/FunGame.Desktop/Models/Config/Config.cs
@@ -27,6 +27,7 @@ namespace FunGame.Desktop.Models.Config
public const string WebHelper_SetGreen = "-WebHelper .set green";
public const string WebHelper_SetGreenAndPing = "-WebHelper .set greenandping";
public const string WebHelper_SetRed = "-WebHelper .set red";
+ public const string WebHelper_SetYellow = "-WebHelper .set yellow";
public const string WebHelper_Disconnected = "-WebHelper .disconnected";
public const string WebHelper_GetUser = "-WebHelper .get user";
public static int WebHelper_HeartBeatFaileds = 0;
diff --git a/FunGame.Desktop/Properties/Resources.Designer.cs b/FunGame.Desktop/Properties/Resources.Designer.cs
index 4d5b5c4..1644e18 100644
--- a/FunGame.Desktop/Properties/Resources.Designer.cs
+++ b/FunGame.Desktop/Properties/Resources.Designer.cs
@@ -139,5 +139,15 @@ namespace FunGame.Desktop.Properties {
return ((System.Drawing.Bitmap)(obj));
}
}
+
+ ///
+ /// 鏌ユ壘 System.Drawing.Bitmap 绫诲瀷鐨勬湰鍦板寲璧勬簮銆
+ ///
+ internal static System.Drawing.Bitmap yellow {
+ get {
+ object obj = ResourceManager.GetObject("yellow", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
}
}
diff --git a/FunGame.Desktop/Properties/Resources.resx b/FunGame.Desktop/Properties/Resources.resx
index 54e14d9..6000db2 100644
--- a/FunGame.Desktop/Properties/Resources.resx
+++ b/FunGame.Desktop/Properties/Resources.resx
@@ -133,13 +133,16 @@
..\images\back.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- ..\images\min.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
..\Images\favicon.ico;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\images\min.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
..\Images\logo.ico;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Images\yellow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/FunGame.Desktop/UI/Main/Main.Designer.cs b/FunGame.Desktop/UI/Main/Main.Designer.cs
index cde0a3b..60f9ca8 100644
--- a/FunGame.Desktop/UI/Main/Main.Designer.cs
+++ b/FunGame.Desktop/UI/Main/Main.Designer.cs
@@ -145,7 +145,7 @@ namespace FunGame.Desktop.UI
this.Light.Image = global::FunGame.Desktop.Properties.Resources.red;
this.Light.Location = new System.Drawing.Point(777, 426);
this.Light.Name = "Light";
- this.Light.Size = new System.Drawing.Size(20, 20);
+ this.Light.Size = new System.Drawing.Size(18, 18);
this.Light.TabIndex = 93;
//
// SendTalkText
@@ -407,7 +407,7 @@ namespace FunGame.Desktop.UI
this.NoticeText.ReadOnly = true;
this.NoticeText.Size = new System.Drawing.Size(174, 86);
this.NoticeText.TabIndex = 0;
- this.NoticeText.Text = "杩欓噷灞曠ず鍏憡";
+ this.NoticeText.Text = "";
//
// InfoBox
//
@@ -452,7 +452,7 @@ namespace FunGame.Desktop.UI
this.GameInfo.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
this.GameInfo.Size = new System.Drawing.Size(452, 331);
this.GameInfo.TabIndex = 1;
- this.GameInfo.Text = "杩欓噷灞曠ず娓告垙淇℃伅锛屽寘鎷郴缁熼氱煡鍜屾父鎴忓弽棣";
+ this.GameInfo.Text = "";
//
// QuitRoom
//
diff --git a/FunGame.Desktop/UI/Main/Main.cs b/FunGame.Desktop/UI/Main/Main.cs
index 4d7e371..7b6a3e2 100644
--- a/FunGame.Desktop/UI/Main/Main.cs
+++ b/FunGame.Desktop/UI/Main/Main.cs
@@ -8,6 +8,7 @@ using System.Text;
using FunGame.Core.Api.Model.Entity;
using FunGame.Desktop.Models.Config;
using FunGame.Desktop.Utils;
+using FunGame.Core.Api.Model.Enum;
using static FunGame.Core.Api.Model.Enum.CommonEnums;
namespace FunGame.Desktop.UI
@@ -53,8 +54,7 @@ namespace FunGame.Desktop.UI
{
this.PresetText.SelectedIndex = 0; // 蹇嵎娑堟伅鍒濆閫夋嫨
SetRoomid("-1"); // 鎴块棿鍙峰垵濮嬪寲
- WritelnGameInfo(); // 鍒濆鍖栨秷鎭槦鍒
- SetLoginUser(new object[] { new User("Mili") }); // Debug锛屽垵濮嬪寲鐜╁鍚嶅瓧
+ ShowFunGameInfo(); // 鏄剧ずFunGame淇℃伅
GetServerConnection(); // 寮濮嬭繛鎺ユ湇鍔″櫒
}
@@ -81,7 +81,7 @@ namespace FunGame.Desktop.UI
Usercfg.FunGame_isRetrying = false;
WebHelper_Action = (main) =>
{
- SetServerStatusLight(true);
+ SetServerStatusLight((int)CommonEnums.LightType.Green);
};
if (InvokeRequired)
BeginInvoke(WebHelper_Action, this);
@@ -94,7 +94,20 @@ namespace FunGame.Desktop.UI
Usercfg.FunGame_isRetrying = false;
WebHelper_Action = (main) =>
{
- SetServerStatusLight(true, GetServerPing(Config.SERVER_IPADRESS));
+ SetServerStatusLight((int)CommonEnums.LightType.Green, GetServerPing(Config.SERVER_IPADRESS));
+ };
+ if (InvokeRequired)
+ BeginInvoke(WebHelper_Action, this);
+ else
+ WebHelper_Action(this);
+ Usercfg.FunGame_isConnected = true;
+ NOW_CONNECTEDRETRY = 0;
+ break;
+ case Config.WebHelper_SetYellow:
+ Usercfg.FunGame_isRetrying = false;
+ WebHelper_Action = (main) =>
+ {
+ SetServerStatusLight((int)CommonEnums.LightType.Yellow);
};
if (InvokeRequired)
BeginInvoke(WebHelper_Action, this);
@@ -106,7 +119,7 @@ namespace FunGame.Desktop.UI
case Config.WebHelper_SetRed:
WebHelper_Action = (main) =>
{
- SetServerStatusLight(false);
+ SetServerStatusLight((int)CommonEnums.LightType.Red);
};
if (InvokeRequired)
BeginInvoke(WebHelper_Action, this);
@@ -118,7 +131,7 @@ namespace FunGame.Desktop.UI
Usercfg.FunGame_isRetrying = false;
WebHelper_Action = (main) =>
{
- SetServerStatusLight(false);
+ SetServerStatusLight((int)CommonEnums.LightType.Red);
};
if (InvokeRequired)
BeginInvoke(WebHelper_Action, this);
@@ -147,7 +160,10 @@ namespace FunGame.Desktop.UI
return LoginUser;
return null;
default:
- WritelnGameInfo(webHelper, msg);
+ if (needTime)
+ WritelnGameInfo(webHelper, GetNowShortTime() + msg);
+ else
+ WritelnGameInfo(webHelper, msg);
return null;
}
}
@@ -188,7 +204,7 @@ namespace FunGame.Desktop.UI
}
catch (Exception e)
{
- WritelnGameInfo(">> 鏌ユ壘鍙敤鐨勬湇鍔″櫒澶辫触锛岃閲嶅惎FunGame锛乗n" + e.StackTrace);
+ WritelnGameInfo(">> 鏌ユ壘鍙敤鐨勬湇鍔″櫒澶辫触锛岃閲嶅惎FunGame銆俓n" + e.StackTrace);
ShowMessage.ErrorMessage("鏌ユ壘鍙敤鐨勬湇鍔″櫒澶辫触锛");
}
}
@@ -683,30 +699,46 @@ namespace FunGame.Desktop.UI
///
/// 璁剧疆鏈嶅姟鍣ㄨ繛鎺ョ姸鎬佹寚绀虹伅
///
- ///
+ ///
///
- private void SetServerStatusLight(bool green, int ping = 0)
+ private void SetServerStatusLight(int light, int ping = 0)
{
- if (green)
+ switch(light)
{
- if (ping > 0)
- {
- Connection.Text = "蹇冭烦寤惰繜 " + ping + "ms";
- this.Light.Image = Properties.Resources.green;
- }
- else
- {
+ case (int)CommonEnums.LightType.Green:
Connection.Text = "鏈嶅姟鍣ㄨ繛鎺ユ垚鍔";
this.Light.Image = Properties.Resources.green;
- }
+ break;
+ case (int)CommonEnums.LightType.Yellow:
+ Connection.Text = "绛夊緟鐧诲綍璐﹀彿";
+ this.Light.Image = Properties.Resources.yellow;
+ break;
+ case (int)CommonEnums.LightType.Red:
+ default:
+ Connection.Text = "鏈嶅姟鍣ㄨ繛鎺ュけ璐";
+ this.Light.Image = Properties.Resources.red;
+ break;
}
- else
+ if (ping > 0)
{
- Connection.Text = "鏈嶅姟鍣ㄨ繛鎺ュけ璐";
- this.Light.Image = Properties.Resources.red;
+ Connection.Text = "蹇冭烦寤惰繜 " + ping + "ms";
+ if (ping < 100)
+ this.Light.Image = Properties.Resources.green;
+ else if (ping >= 100 && ping < 200)
+ this.Light.Image = Properties.Resources.yellow;
+ else if (ping >= 200)
+ this.Light.Image = Properties.Resources.red;
}
}
+ ///
+ /// 鏄剧ずFunGame淇℃伅
+ ///
+ private void ShowFunGameInfo()
+ {
+ WritelnGameInfo(FunGameEnums.GetVersion());
+ }
+
#endregion
#region 浜嬩欢
diff --git a/FunGame.Desktop/Utils/WebHelper.cs b/FunGame.Desktop/Utils/WebHelper.cs
index bce8813..ed03872 100644
--- a/FunGame.Desktop/Utils/WebHelper.cs
+++ b/FunGame.Desktop/Utils/WebHelper.cs
@@ -66,7 +66,7 @@ namespace FunGame.Desktop.Utils
client.Connect(server);
if (IsConnected())
{
- Main.GetMessage(this, Config.WebHelper_SetGreen);
+ Main.GetMessage(this, Config.WebHelper_SetYellow);
break;
}
}
@@ -79,12 +79,8 @@ namespace FunGame.Desktop.Utils
objs = new object[] { main, socket, obj };
else
objs = new object[] { main, socket };
- Task.Factory.StartNew(() =>
- {
-
- });
- if (Send((int)SocketEnums.Type.CheckLogin, objs)) // 纭杩炴帴鐨勭帺瀹
- StartWebHelper(); // 寮濮嬪垱寤篢CP娴
+ if (Send((int)CommonEnums.SocketType.GetNotice, objs)) // 鎺ヨЕ鏈嶅姟鍣ㄥ苟鑾峰彇鍏憡
+ main.GetMessage(this, " >> 杩炴帴鏈嶅姟鍣ㄦ垚鍔燂紝璇风櫥褰曡处鍙蜂互浣撻獙FunGame銆", true);
};
Task t = Task.Factory.StartNew(() =>
{
@@ -142,25 +138,28 @@ namespace FunGame.Desktop.Utils
{
string msg = Config.DEFAULT_ENCODING.GetString(buffer, 0, length);
int type = GetType(msg);
- string typestring = GetTypeString(type);
+ string typestring = CommonEnums.GetSocketTypeName(type);
string read = GetMessage(msg);
- main.GetMessage(this, read);
switch (type)
{
- case (int)SocketEnums.Type.GetNotice:
- break;
- case (int)SocketEnums.Type.Login:
- break;
- case (int)SocketEnums.Type.CheckLogin:
+ case (int)CommonEnums.SocketType.GetNotice:
+ main.GetMessage(this, read, true);
return true;
- case (int)SocketEnums.Type.Logout:
+ case (int)CommonEnums.SocketType.Login:
break;
- case (int)SocketEnums.Type.HeartBeat:
+ case (int)CommonEnums.SocketType.CheckLogin:
+ StartWebHelper(); // 寮濮嬪垱寤篢CP娴
+ return true;
+ case (int)CommonEnums.SocketType.Logout:
+ break;
+ case (int)CommonEnums.SocketType.HeartBeat:
if (WaitHeartBeat != null && !WaitHeartBeat.IsCompleted) WaitHeartBeat.Wait(1);
Config.WebHelper_HeartBeatFaileds = 0;
main.GetMessage(this, Config.WebHelper_SetGreenAndPing);
return true;
}
+ main.GetMessage(this, read);
+ return true;
}
else
throw new Exception("ERROR锛氭湭鏀跺埌浠讳綍鏉ヨ嚜鏈嶅姟鍣ㄧ殑淇℃伅锛屼笌鏈嶅姟鍣ㄨ繛鎺ュ彲鑳戒涪澶便");
@@ -198,16 +197,26 @@ namespace FunGame.Desktop.Utils
}
if (socket != null)
{
+ string msg = "";
+ byte[] buffer;
+ int length;
// 鍙戦佹秷鎭粰鏈嶅姟鍣ㄧ
switch (i)
{
- case (int)SocketEnums.Type.GetNotice:
+ case (int)CommonEnums.SocketType.GetNotice:
+ msg = "鑾峰彇鍏憡";
+ buffer = new byte[2048];
+ buffer = Config.DEFAULT_ENCODING.GetBytes(MakeMessage((int)CommonEnums.SocketType.GetNotice, msg));
+ length = socket.Send(buffer);
+ if (length > 0)
+ {
+ return Read(objs);
+ }
break;
- case (int)SocketEnums.Type.Login:
+ case (int)CommonEnums.SocketType.Login:
break;
- case (int)SocketEnums.Type.CheckLogin:
+ case (int)CommonEnums.SocketType.CheckLogin:
User user;
- string msg;
if (objs != null && objs.Length > 2)
{
user = (User)objs[2];
@@ -216,22 +225,22 @@ namespace FunGame.Desktop.Utils
else
{
Usercfg.FunGame_isAutoRetry = false;
- throw new Exception("SUCCESS锛氭湇鍔″櫒杩炴帴鎴愬姛锛屾娴嬪埌鏈櫥褰曡处鍙峰凡鑷姩鏂紑锛岃鐧诲綍鍚庢墜鍔ㄥ彂璧锋湇鍔″櫒杩炴帴銆");
+ throw new Exception("ERROR: 璇风櫥褰曡处鍙枫");
}
- byte[] buffer = new byte[2048];
- buffer = Config.DEFAULT_ENCODING.GetBytes(MakeMessage((int)SocketEnums.Type.CheckLogin, msg));
- int l = socket.Send(buffer);
- if (l > 0)
+ buffer = new byte[2048];
+ buffer = Config.DEFAULT_ENCODING.GetBytes(MakeMessage((int)CommonEnums.SocketType.CheckLogin, msg));
+ length = socket.Send(buffer);
+ if (length > 0)
{
return Read(objs);
}
else
throw new Exception("ERROR锛氭秷鎭湭閫佽揪鏈嶅姟鍣紝涓庢湇鍔″櫒杩炴帴鍙兘涓㈠け銆");
- case (int)SocketEnums.Type.Logout:
+ case (int)CommonEnums.SocketType.Logout:
break;
- case (int)SocketEnums.Type.HeartBeat:
+ case (int)CommonEnums.SocketType.HeartBeat:
buffer = new byte[2048];
- buffer = Config.DEFAULT_ENCODING.GetBytes(Convert.ToString(MakeMessage((int)SocketEnums.Type.HeartBeat, "蹇冭烦妫娴")));
+ buffer = Config.DEFAULT_ENCODING.GetBytes(Convert.ToString(MakeMessage((int)CommonEnums.SocketType.HeartBeat, "蹇冭烦妫娴")));
if (socket.Send(buffer) > 0)
{
WaitHeartBeat = Task.Run(() =>
@@ -292,25 +301,6 @@ namespace FunGame.Desktop.Utils
return Convert.ToInt32(msg[..1]);
}
- private string GetTypeString(int type)
- {
- switch (type)
- {
- case (int)SocketEnums.Type.GetNotice:
- return SocketEnums.TYPE_GetNotice;
- case (int)SocketEnums.Type.Login:
- return SocketEnums.TYPE_Login;
- case (int)SocketEnums.Type.CheckLogin:
- return SocketEnums.TYPE_CheckLogin;
- case (int)SocketEnums.Type.Logout:
- return SocketEnums.TYPE_Logout;
- case (int)SocketEnums.Type.HeartBeat:
- return SocketEnums.TYPE_HeartBeat;
- default:
- return SocketEnums.TYPE_UNKNOWN;
- }
- }
-
private string GetMessage(string msg)
{
int index = msg.IndexOf(';') + 1;
@@ -353,7 +343,7 @@ namespace FunGame.Desktop.Utils
Main.GetMessage(this, "Creating: SendHeartBeatStream...OK");
while (IsConnected())
{
- Send((int)SocketEnums.Type.HeartBeat); // 鍙戦佸績璺冲寘
+ Send((int)CommonEnums.SocketType.HeartBeat); // 鍙戦佸績璺冲寘
Thread.Sleep(20000);
}
}