diff --git a/Lib/Net4x/HaoYueNet.ClientNetworkNet4x.dll b/Lib/Net4x/HaoYueNet.ClientNetworkNet4x.dll deleted file mode 100644 index b71c2fd..0000000 Binary files a/Lib/Net4x/HaoYueNet.ClientNetworkNet4x.dll and /dev/null differ diff --git a/Lib/Net4x/HaoYueNet.ServerNetworkNet4x.dll b/Lib/Net4x/HaoYueNet.ServerNetworkNet4x.dll deleted file mode 100644 index f57bef1..0000000 Binary files a/Lib/Net4x/HaoYueNet.ServerNetworkNet4x.dll and /dev/null differ diff --git a/Lib/Net4x/System.Buffers.dll b/Lib/Net4x/System.Buffers.dll deleted file mode 100644 index 14e5c53..0000000 Binary files a/Lib/Net4x/System.Buffers.dll and /dev/null differ diff --git a/Lib/Net4x/System.Memory.dll b/Lib/Net4x/System.Memory.dll deleted file mode 100644 index 31486d6..0000000 Binary files a/Lib/Net4x/System.Memory.dll and /dev/null differ diff --git a/Lib/Net4x/System.Runtime.CompilerServices.Unsafe.dll b/Lib/Net4x/System.Runtime.CompilerServices.Unsafe.dll deleted file mode 100644 index b50dbc4..0000000 Binary files a/Lib/Net4x/System.Runtime.CompilerServices.Unsafe.dll and /dev/null differ diff --git a/Lib/NetLib_Standard2/HaoYueNet.ClientNetworkNet.Standard2.dll b/Lib/NetLib_Standard2/HaoYueNet.ClientNetworkNet.Standard2.dll new file mode 100644 index 0000000..c3c4a90 Binary files /dev/null and b/Lib/NetLib_Standard2/HaoYueNet.ClientNetworkNet.Standard2.dll differ diff --git a/Lib/NetLib_Standard2/HaoYueNet.ServerNetwork.Standard2.dll b/Lib/NetLib_Standard2/HaoYueNet.ServerNetwork.Standard2.dll new file mode 100644 index 0000000..f525fd2 Binary files /dev/null and b/Lib/NetLib_Standard2/HaoYueNet.ServerNetwork.Standard2.dll differ diff --git a/Lib/NetLib_Standard2/NoSugarNet.DataHelper.deps.json b/Lib/NetLib_Standard2/NoSugarNet.DataHelper.deps.json new file mode 100644 index 0000000..eb9bf4e --- /dev/null +++ b/Lib/NetLib_Standard2/NoSugarNet.DataHelper.deps.json @@ -0,0 +1,47 @@ +{ + "runtimeTarget": { + "name": ".NETStandard,Version=v2.0/", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETStandard,Version=v2.0": {}, + ".NETStandard,Version=v2.0/": { + "NoSugarNet.DataHelper/1.0.0": { + "dependencies": { + "NETStandard.Library": "2.0.3" + }, + "runtime": { + "NoSugarNet.DataHelper.dll": {} + } + }, + "Microsoft.NETCore.Platforms/1.1.0": {}, + "NETStandard.Library/2.0.3": { + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + } + } + }, + "libraries": { + "NoSugarNet.DataHelper/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "Microsoft.NETCore.Platforms/1.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==", + "path": "microsoft.netcore.platforms/1.1.0", + "hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512" + }, + "NETStandard.Library/2.0.3": { + "type": "package", + "serviceable": true, + "sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "path": "netstandard.library/2.0.3", + "hashPath": "netstandard.library.2.0.3.nupkg.sha512" + } + } +} \ No newline at end of file diff --git a/Lib/NetLib_Standard2/NoSugarNet.DataHelper.dll b/Lib/NetLib_Standard2/NoSugarNet.DataHelper.dll new file mode 100644 index 0000000..46e3832 Binary files /dev/null and b/Lib/NetLib_Standard2/NoSugarNet.DataHelper.dll differ diff --git a/Lib/NetLib_Standard2/NoSugarNet.DataHelper.pdb b/Lib/NetLib_Standard2/NoSugarNet.DataHelper.pdb new file mode 100644 index 0000000..d7ba2a9 Binary files /dev/null and b/Lib/NetLib_Standard2/NoSugarNet.DataHelper.pdb differ diff --git a/NoSugarNet.ClientCore.Standard2/App.config b/NoSugarNet.ClientCore.Standard2/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/NoSugarNet.ClientCore.Standard2/AppNoSugarNet.cs b/NoSugarNet.ClientCore.Standard2/AppNoSugarNet.cs new file mode 100644 index 0000000..a6e4847 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/AppNoSugarNet.cs @@ -0,0 +1,84 @@ +using NoSugarNet.ClientCoreNet.Standard2.Manager; +using NoSugarNet.ClientCoreNet.Standard2.Network; +using ServerCore.Manager; +using static NoSugarNet.ClientCoreNet.Standard2.Manager.LogManager; + +namespace NoSugarNet.ClientCoreNet.Standard2 +{ + public class AppNoSugarNet + { + public static string TokenStr; + public static long RID = -1; + public static string IP; + public static int Port; + public static LogManager log; + public static NetworkHelper networkHelper; + public static AppLogin login; + public static AppChat chat; + public static AppLocalClient local; + public static UserDataManager user; + public static System.Timers.Timer _SpeedCheckTimeTimer;//速度检测计时器 + public static int TimerInterval = 1000;//计时器间隔 + static NetStatus netStatus; + + #region 委托和事件 + public delegate void OnUpdateStatusHandler(NetStatus Status); + public static event OnUpdateStatusHandler OnUpdateStatus; + #endregion + + public static void Init(OnLogHandler onLog = null) + { + log = new LogManager(); + if(onLog != null) + LogManager.OnLog += onLog; + networkHelper = new NetworkHelper(); + login = new AppLogin(); + chat = new AppChat(); + local = new AppLocalClient(); + user = new UserDataManager(); + netStatus = new NetStatus(); + _SpeedCheckTimeTimer = new System.Timers.Timer(); + _SpeedCheckTimeTimer.Interval = TimerInterval; + _SpeedCheckTimeTimer.Elapsed += Checktimer_Elapsed; + _SpeedCheckTimeTimer.AutoReset = true; + } + + public static void Connect(string IP, int port) + { + if (networkHelper.Init(IP, port)) + _SpeedCheckTimeTimer.Enabled = true; + else + _SpeedCheckTimeTimer.Enabled = false; + } + + public static void Close() + { + local.StopAll(); + networkHelper.CloseConntect(); + AppNoSugarNet.log.Info("停止"); + _SpeedCheckTimeTimer.Enabled = false; + } + + static void Checktimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + local.GetCurrLenght(out long resultReciveAllLenght, out long resultSendAllLenght); + local.GetClientCount(out int ClientUserCount, out int TunnelCount); + + NetStatus resutnetStatus = new NetStatus() + { + TunnelCount = TunnelCount, + ClientUserCount = ClientUserCount, + srcSendAllLenght = resultSendAllLenght, + srcReciveAllLenght = resultReciveAllLenght, + srcReciveSecSpeed = (resultReciveAllLenght - netStatus.srcReciveAllLenght) / (TimerInterval / 1000), + srcSendSecSpeed = (resultSendAllLenght - netStatus.srcSendAllLenght) / (TimerInterval / 1000), + tSendAllLenght = local.tSendAllLenght, + tReciveAllLenght = local.tReciveAllLenght, + tSendSecSpeed = (local.tSendAllLenght - netStatus.tSendAllLenght) / (TimerInterval / 1000), + tReciveSecSpeed = (local.tReciveAllLenght - netStatus.tReciveAllLenght) / (TimerInterval / 1000), + }; + netStatus = resutnetStatus; + OnUpdateStatus?.Invoke(resutnetStatus); + } + } +} \ No newline at end of file diff --git a/NoSugarNet.ClientCore.Standard2/Common/Helper.cs b/NoSugarNet.ClientCore.Standard2/Common/Helper.cs new file mode 100644 index 0000000..8daba3e --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Common/Helper.cs @@ -0,0 +1,22 @@ +using System; + +namespace NoSugarNet.ClientCoreNet.Standard2.Common +{ + public static class Helper + { + public static long GetNowTimeStamp() + { + return GetTimeStamp(DateTime.Now); + } + + /// + /// 获取时间戳 + /// + /// + public static long GetTimeStamp(DateTime dt) + { + TimeSpan ts = dt - new DateTime(1970, 1, 1, 0, 0, 0, 0); + return Convert.ToInt64(ts.TotalSeconds); + } + } +} diff --git a/NoSugarNet.ClientCore.Standard2/Common/ProtoBufHelper.cs b/NoSugarNet.ClientCore.Standard2/Common/ProtoBufHelper.cs new file mode 100644 index 0000000..3c229bc --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Common/ProtoBufHelper.cs @@ -0,0 +1,21 @@ +using Google.Protobuf; +using System; + +namespace NoSugarNet.ClientCoreNet.Standard2.Common +{ + public static class ProtoBufHelper + { + public static byte[] Serizlize(IMessage msg) + { + return msg.ToByteArray(); + } + public static T DeSerizlize(byte[] bytes) + { + var msgType = typeof(T); + object msg = Activator.CreateInstance(msgType); + ((IMessage)msg).MergeFrom(bytes); + return (T)msg; + } + } + +} diff --git a/NoSugarNet.ClientCore.Standard2/Event/EEvent.cs b/NoSugarNet.ClientCore.Standard2/Event/EEvent.cs new file mode 100644 index 0000000..5e1e9f4 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Event/EEvent.cs @@ -0,0 +1,8 @@ +namespace NoSugarNet.ClientCoreNet.Standard2.Event +{ + public enum EEvent + { + // 添加你自己需要的事件类型 + OnChatMsg + } +} diff --git a/NoSugarNet.ClientCore.Standard2/Event/EventSystem.cs b/NoSugarNet.ClientCore.Standard2/Event/EventSystem.cs new file mode 100644 index 0000000..b4f4d92 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Event/EventSystem.cs @@ -0,0 +1,241 @@ +using System; +using System.Collections.Generic; + +namespace NoSugarNet.ClientCoreNet.Standard2.Event +{ + public class EventData + { + private static long BaseUid = 0; + private static long GenUid() + { + return (++BaseUid); + } + + /// + /// 唯一id + /// + public long uid { get; private set; } + + /// + /// 回调 + /// + public Delegate callback { get; private set; } + + public EventData(Delegate d) + { + uid = GenUid(); + callback = d; + } + } + + public class EventSystem + { + private static EventSystem instance = new EventSystem(); + public static EventSystem Instance { get { return instance; } } + + private Dictionary> eventDic = new Dictionary>(128); + + private EventSystem() { } + + + #region RegisterEvent + public void RegisterEvent(EEvent evt, Action callback) + { + InterRegisterEvent(evt, callback); + } + + public void RegisterEvent(EEvent evt, Action callback) + { + InterRegisterEvent(evt, callback); + } + + public void RegisterEvent(EEvent evt, Action callback) + { + InterRegisterEvent(evt, callback); + } + + public void RegisterEvent(EEvent evt, Action callback) + { + InterRegisterEvent(evt, callback); + } + + public void RegisterEvent(EEvent evt, Action callback) + { + InterRegisterEvent(evt, callback); + } + + private void InterRegisterEvent(EEvent evt, Delegate callback) + { + if (eventDic.ContainsKey(evt)) + { + if (eventDic[evt].IndexOf(callback) < 0) + { + eventDic[evt].Add(callback); + } + } + else + { + eventDic.Add(evt, new List() { callback }); + } + } + #endregion + + #region UnregisterEvent + + public void UnregisterEvent(EEvent evt, Action callback) + { + Delegate tempDelegate = callback; + InterUnregisterEvent(evt, tempDelegate); + } + + public void UnregisterEvent(EEvent evt, Action callback) + { + Delegate tempDelegate = callback; + InterUnregisterEvent(evt, tempDelegate); + } + + public void UnregisterEvent(EEvent evt, Action callback) + { + Delegate tempDelegate = callback; + InterUnregisterEvent(evt, tempDelegate); + } + + public void UnregisterEvent(EEvent evt, Action callback) + { + Delegate tempDelegate = callback; + InterUnregisterEvent(evt, tempDelegate); + } + + public void UnregisterEvent(EEvent evt, Action callback) + { + Delegate tempDelegate = callback; + InterUnregisterEvent(evt, tempDelegate); + } + + private void InterUnregisterEvent(EEvent evt, Delegate callback) + { + if (eventDic.ContainsKey(evt)) + { + eventDic[evt].Remove(callback); + if (eventDic[evt].Count == 0) eventDic.Remove(evt); + } + } + #endregion + + #region PostEvent + public void PostEvent(EEvent evt, T1 arg1, T2 arg2, T3 arg3, T4 arg4) + { + List eventList = GetEventList(evt); + if (eventList != null) + { + foreach (Delegate callback in eventList) + { + try + { + ((Action)callback)(arg1, arg2, arg3, arg4); + } + catch (Exception e) + { + AppNoSugarNet.log.Error(e.Message); + } + } + } + } + + public void PostEvent(EEvent evt, T1 arg1, T2 arg2, T3 arg3) + { + List eventList = GetEventList(evt); + if (eventList != null) + { + foreach (Delegate callback in eventList) + { + try + { + ((Action)callback)(arg1, arg2, arg3); + } + catch (Exception e) + { + AppNoSugarNet.log.Error(e.Message); + } + } + } + } + + public void PostEvent(EEvent evt, T1 arg1, T2 arg2) + { + List eventList = GetEventList(evt); + if (eventList != null) + { + foreach (Delegate callback in eventList) + { + try + { + ((Action)callback)(arg1, arg2); + } + catch (Exception e) + { + AppNoSugarNet.log.Error(e.Message); + } + } + } + } + + public void PostEvent(EEvent evt, T arg) + { + List eventList = GetEventList(evt); + if (eventList != null) + { + foreach (Delegate callback in eventList) + { + try + { + ((Action)callback)(arg); + } + catch (Exception e) + { + AppNoSugarNet.log.Error(e.Message + ", method name : " + callback.Method); + } + } + } + + } + + public void PostEvent(EEvent evt) + { + List eventList = GetEventList(evt); + if (eventList != null) + { + foreach (Delegate callback in eventList) + { + try + { + ((Action)callback)(); + } + catch (Exception e) + { + AppNoSugarNet.log.Error(e.Message); + } + } + } + } + #endregion + + /// + /// 获取所有事件 + /// + /// + /// + private List GetEventList(EEvent evt) + { + if (eventDic.ContainsKey(evt)) + { + List tempList = eventDic[evt]; + if (null != tempList) + { + return tempList; + } + } + return null; + } + } +} diff --git a/NoSugarNet.ClientCore.Standard2/Manager/AppChat.cs b/NoSugarNet.ClientCore.Standard2/Manager/AppChat.cs new file mode 100644 index 0000000..68b1635 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Manager/AppChat.cs @@ -0,0 +1,30 @@ +using AxibugProtobuf; +using NoSugarNet.ClientCoreNet.Standard2.Common; +using NoSugarNet.ClientCoreNet.Standard2.Event; +using NoSugarNet.ClientCoreNet.Standard2.Network; + +namespace NoSugarNet.ClientCoreNet.Standard2.Manager +{ + public class AppChat + { + public AppChat() + { + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdChatmsg, RecvChatMsg); + } + + public void SendChatMsg(string ChatMsg) + { + Protobuf_ChatMsg msg = new Protobuf_ChatMsg() + { + ChatMsg = ChatMsg, + }; + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdChatmsg, ProtoBufHelper.Serizlize(msg)); + } + + public void RecvChatMsg(byte[] reqData) + { + Protobuf_ChatMsg_RESP msg = ProtoBufHelper.DeSerizlize(reqData); + EventSystem.Instance.PostEvent(EEvent.OnChatMsg, msg.NickName, msg.ChatMsg); + } + } +} diff --git a/NoSugarNet.ClientCore.Standard2/Manager/AppLocalClient.cs b/NoSugarNet.ClientCore.Standard2/Manager/AppLocalClient.cs new file mode 100644 index 0000000..1324112 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Manager/AppLocalClient.cs @@ -0,0 +1,337 @@ +using AxibugProtobuf; +using Google.Protobuf; +using NoSugarNet.ClientCoreNet.Standard2; +using NoSugarNet.ClientCoreNet.Standard2.Common; +using NoSugarNet.ClientCoreNet.Standard2.Network; +using NoSugarNet.DataHelper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; + +namespace ServerCore.Manager +{ + public class AppLocalClient + { + Dictionary mDictTunnelID2Cfg = new Dictionary(); + Dictionary mDictTunnelID2Listeners = new Dictionary(); + CompressAdapter mCompressAdapter; + E_CompressAdapter compressAdapterType; + public LocalMsgQueuePool _localMsgPool = new LocalMsgQueuePool(1000); + + public long tReciveAllLenght { get; private set; } + public long tSendAllLenght { get; private set; } + + public AppLocalClient() + { + //注册网络消息 + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdCfgs, Recive_CmdCfgs); + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CConnect, Recive_TunnelS2CConnect); + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CDisconnect, Recive_TunnelS2CDisconnect); + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdTunnelS2CData, Recive_TunnelS2CData); + } + + public void GetCurrLenght(out long resultReciveAllLenght, out long resultSendAllLenght) + { + resultReciveAllLenght = 0; + resultSendAllLenght = 0; + byte[] Keys = mDictTunnelID2Listeners.Keys.ToArray(); + for (int i = 0; i < Keys.Length; i++) + { + //local和转发 收发相反 + resultSendAllLenght += mDictTunnelID2Listeners[Keys[i]].mReciveAllLenght; + resultReciveAllLenght += mDictTunnelID2Listeners[Keys[i]].mSendAllLenght; + } + } + + + public void GetClientCount(out int ClientUserCount, out int TunnelCount) + { + TunnelCount = mDictTunnelID2Listeners.Count; + ClientUserCount = mDictTunnelID2Listeners.Count; + } + + /// + /// 初始化连接,先获取到配置 + /// + void InitListenerMode() + { + AppNoSugarNet.log.Info("初始化压缩适配器" + compressAdapterType); + //初始化压缩适配器,代表压缩类型 + mCompressAdapter = new CompressAdapter(compressAdapterType); + foreach (var cfg in mDictTunnelID2Cfg) + { + LocalListener listener = new LocalListener(256, 1024, cfg.Key); + AppNoSugarNet.log.Info($"开始监听配置 Tunnel:{cfg.Key},Port:{cfg.Value.Port}"); + listener.Init(); + listener.Start(new IPEndPoint(IPAddress.Any.Address, (int)cfg.Value.Port)); + //listener.Init((int)cfg.Value.Port); + AddLocalListener(listener); + } + + } + + #region 连接字典管理 + /// + /// 追加监听者 + /// + /// + /// + void AddLocalListener(LocalListener _listener) + { + lock (mDictTunnelID2Listeners) + { + mDictTunnelID2Listeners[_listener.mTunnelID] = _listener; + } + } + /// + /// 删除监听 + /// + /// + /// + void RemoveLocalListener(LocalListener _listener) + { + lock (mDictTunnelID2Listeners) + { + if (mDictTunnelID2Listeners.ContainsKey(_listener.mTunnelID)) + { + mDictTunnelID2Listeners.Remove(_listener.mTunnelID); + } + } + } + bool GetLocalListener(byte tunnelId,out LocalListener _listener) + { + _listener = null; + if (!mDictTunnelID2Listeners.ContainsKey(tunnelId)) + return false; + + _listener = mDictTunnelID2Listeners[tunnelId]; + return true; + } + public void StopAll() + { + lock (mDictTunnelID2Listeners) + { + byte[] keys = mDictTunnelID2Listeners.Keys.ToArray(); + for (int i = 0; i < keys.Length; i++) + { + LocalListener _listener = mDictTunnelID2Listeners[keys[i]]; + _listener.StopAll(); + //_listener.Stop(); + RemoveLocalListener(_listener); + } + } + } + #endregion + + #region 解析服务端下行数据 + public void Recive_CmdCfgs(byte[] reqData) + { + AppNoSugarNet.log.Debug("Recive_CmdCfgs"); + Protobuf_Cfgs msg = ProtoBufHelper.DeSerizlize(reqData); + + for (int i = 0;i < msg.Cfgs.Count;i++) + { + Protobuf_Cfgs_Single cfg = msg.Cfgs[i]; + mDictTunnelID2Cfg[(byte)cfg.TunnelID] = cfg; + } + compressAdapterType = (E_CompressAdapter)msg.CompressAdapterType; + InitListenerMode(); + } + public void Recive_TunnelS2CConnect(byte[] reqData) + { + AppNoSugarNet.log.Debug("Recive_TunnelS2CConnect"); + Protobuf_S2C_Connect msg = ProtoBufHelper.DeSerizlize(reqData); + if(msg.Connected == 1) + OnServerLocalConnect((byte)msg.TunnelID,(byte)msg.Idx); + else + OnServerLocalDisconnect((byte)msg.TunnelID, (byte)msg.Idx); + } + public void Recive_TunnelS2CDisconnect(byte[] reqData) + { + AppNoSugarNet.log.Debug("Recive_TunnelS2CDisconnect"); + Protobuf_S2C_Disconnect msg = ProtoBufHelper.DeSerizlize(reqData); + OnServerLocalDisconnect((byte)msg.TunnelID,(byte)msg.Idx); + } + public void Recive_TunnelS2CData(byte[] reqData) + { + //AppNoSugarNet.log.Debug("Recive_TunnelS2CData"); + Protobuf_S2C_DATA msg = ProtoBufHelper.DeSerizlize(reqData); + OnServerLocalDataCallBack((byte)msg.TunnelID,(byte)msg.Idx, msg.HunterNetCoreData.ToArray()); + } + #endregion + + #region 两端本地端口连接事件通知 + /// + /// 当客户端本地端口连接 + /// + /// + /// + public void OnClientLocalConnect(byte tunnelId,byte _Idx) + { + AppNoSugarNet.log.Debug($"OnClientLocalConnect {tunnelId},{_Idx}"); + if (!mDictTunnelID2Cfg.ContainsKey(tunnelId)) + return; + + byte[] respData = ProtoBufHelper.Serizlize(new Protobuf_C2S_Connect() + { + TunnelID = tunnelId, + Idx = _Idx, + }); + + //告知给服务端,来自客户端本地的连接建立 + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelC2SConnect, respData); + } + /// + /// 当客户端本地端口连接断开 + /// + /// + /// + public void OnClientLocalDisconnect(byte tunnelId, byte _Idx) + { + AppNoSugarNet.log.Debug($"OnClientLocalDisconnect {tunnelId},{_Idx}"); + //隧道ID定位投递服务端本地连接 + if (!mDictTunnelID2Cfg.ContainsKey(tunnelId)) + return; + + byte[] respData = ProtoBufHelper.Serizlize(new Protobuf_C2S_Disconnect() + { + TunnelID = tunnelId, + Idx= _Idx, + }); + + //告知给服务端,来自客户端本地的连接断开 + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelC2SDisconnect, respData); + } + + /// + /// 当服务端本地端口连接 + /// + /// + public void OnServerLocalConnect(byte tunnelId,byte Idx) + { + AppNoSugarNet.log.Debug($"OnServerLocalConnect {tunnelId},{Idx}"); + if (!GetLocalListener(tunnelId, out LocalListener _listener)) + return; + //维护状态 + _listener.SetRemoteConnectd(Idx, true); + if (_listener.GetDictMsgQueue(Idx, out List msglist)) + { + for(int i = 0; i < msglist.Count; i++) + { + IdxWithMsg msg = msglist[i]; + //投递给服务端,来自客户端本地的连接数据 + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelC2SData, msg.data); + //发送后回收 + AppNoSugarNet.local._localMsgPool.Enqueue(msg); + } + } + } + /// + /// 当服务端本地端口连接断开 + /// + /// + /// + public void OnServerLocalDisconnect(byte tunnelId, byte Idx) + { + AppNoSugarNet.log.Debug($"OnServerLocalDisconnect {tunnelId},{Idx}"); + if (!GetLocalListener(tunnelId, out LocalListener _listener)) + return; + _listener.SetRemoteConnectd(Idx,false); + _listener.CloseConnectByIdx(Idx); + } + #endregion + + #region 数据投递 + /// + /// 来自服务端本地连接投递的Tunnel数据 + /// + /// + /// + /// + public void OnServerLocalDataCallBack(byte tunnelId,byte Idx, byte[] data) + { + //AppNoSugarNet.log.Info($"OnServerLocalDataCallBack {tunnelId},{Idx},Data长度:{data.Length}"); + if (!GetLocalListener(tunnelId, out LocalListener _listener)) + return; + //记录压缩前数据长度 + tReciveAllLenght += data.Length; + //解压 + data = mCompressAdapter.Decompress(data); + _listener.SendSocketByIdx(Idx,data); + } + /// + /// 来自客户端本地连接投递的Tunnel数据 + /// + /// + /// + /// + public void OnClientTunnelDataCallBack(byte tunnelId,byte Idx, byte[] data) + { + //AppNoSugarNet.log.Info($"OnClientTunnelDataCallBack {tunnelId},{Idx}"); + + int SlienLenght = 1000; + //判断数据量大时分包 + if (data.Length > SlienLenght) + { + byte[] tempSpan = data; + byte[] tempSpanSlien = null; + int PageCount = (int)(data.Length / SlienLenght); + if (data.Length % SlienLenght > 0) + { + PageCount++; + } + + for (int i = 0; i < PageCount; i++) + { + tempSpanSlien = new byte[SlienLenght]; + int StartIdx = i * SlienLenght; + if (i != PageCount - 1)//不是最后一个包 + Array.Copy(tempSpan, StartIdx, tempSpanSlien, 0, SlienLenght); + else//最后一个 + Array.Copy(tempSpan, StartIdx, tempSpanSlien, 0, tempSpanSlien.Length - StartIdx); + + SendDataToRemote(tunnelId, Idx, tempSpanSlien); + + /*if (i != PageCount - 1)//不是最后一个包 + tempSpanSlien = tempSpan.Slice(StartIdx, SlienLenght); + else//最后一个 + tempSpanSlien = tempSpan.Slice(StartIdx); + + SendDataToRemote(tunnelId, Idx, tempSpanSlien.ToArray());*/ + } + return; + } + SendDataToRemote(tunnelId, Idx, data); + } + + void SendDataToRemote(byte tunnelId, byte Idx, byte[] data) + { + //压缩 + data = mCompressAdapter.Compress(data); + //记录压缩后数据长度 + tSendAllLenght += data.Length; + + byte[] respData = ProtoBufHelper.Serizlize(new Protobuf_C2S_DATA() + { + TunnelID = tunnelId, + Idx = Idx, + HunterNetCoreData = ByteString.CopyFrom(data) + }); + + if (!GetLocalListener(tunnelId, out LocalListener _listener)) + return; + + //远程未连接,添加到缓存 + if (!_listener.CheckRemoteConnect(Idx)) + { + _listener.EnqueueIdxWithMsg(Idx, respData); + return; + } + //投递给服务端,来自客户端本地的连接数据 + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdTunnelC2SData, respData); + } + #endregion + + } +} \ No newline at end of file diff --git a/NoSugarNet.ClientCore.Standard2/Manager/AppLogin.cs b/NoSugarNet.ClientCore.Standard2/Manager/AppLogin.cs new file mode 100644 index 0000000..d9684d3 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Manager/AppLogin.cs @@ -0,0 +1,38 @@ +using AxibugProtobuf; +using NoSugarNet.ClientCoreNet.Standard2.Common; +using NoSugarNet.ClientCoreNet.Standard2.Network; + +namespace NoSugarNet.ClientCoreNet.Standard2.Manager +{ + public class AppLogin + { + public AppLogin() + { + NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdLogin, RecvLoginMsg); + } + public void Login(string Account) + { + Protobuf_Login msg = new Protobuf_Login() + { + LoginType = 0, + Account = Account, + }; + AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdLogin, ProtoBufHelper.Serizlize(msg)); + } + + public void RecvLoginMsg(byte[] reqData) + { + Protobuf_Login_RESP msg = ProtoBufHelper.DeSerizlize(reqData); + if (msg.Status == LoginResultStatus.Ok) + { + AppNoSugarNet.log.Info("登录成功"); + AppNoSugarNet.user.InitMainUserData(AppNoSugarNet.user.userdata.Account); + } + else + { + AppNoSugarNet.log.Info("登录失败"); + } + } + + } +} diff --git a/NoSugarNet.ClientCore.Standard2/Manager/LocalClient/LocalListener.cs b/NoSugarNet.ClientCore.Standard2/Manager/LocalClient/LocalListener.cs new file mode 100644 index 0000000..641023b --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Manager/LocalClient/LocalListener.cs @@ -0,0 +1,264 @@ +using HaoYueNet.ServerNetwork.Standard2; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Sockets; + +namespace NoSugarNet.ClientCoreNet.Standard2 +{ + public class LocalListener : TcpSaeaServer_SourceMode + { + public byte mTunnelID; + public long mReciveAllLenght; + public long mSendAllLenght; + public LocalListener(int numConnections, int receiveBufferSize, byte TunnelID) + : base(numConnections, receiveBufferSize) + { + OnClientNumberChange += ClientNumberChange; + OnReceive += ReceiveData; + OnDisconnected += OnDisconnect; + OnNetLog += OnShowNetLog; + + mTunnelID = TunnelID; + } + + private void ClientNumberChange(int num, AsyncUserToken token) + { + AppNoSugarNet.log.Info("Client数发生变化"); + //增加连接数 + if (num > 0) + { + int Idx = AddDictSocket(token.Socket); + if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInf)) + { + AppNoSugarNet.local.OnClientLocalConnect(mTunnelID, (byte)Idx); + } + } + } + + /// + /// 通过下标发送 + /// + /// + /// + public void SendSocketByIdx(int Idx, byte[] data) + { + if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo)) + { + mSendAllLenght += data.Length; + SendToSocket(_localClientInfo._socket, data); + } + //TODO连接前缓存数据 + } + + /// + /// 接受包回调 + /// + /// 协议ID + /// 错误编号 + /// 业务数据 + private void ReceiveData(AsyncUserToken token, byte[] data) + { + DataCallBack(token.Socket, data); + } + + public void DataCallBack(Socket sk, byte[] data) + { + //AppNoSugarNet.log.Info("收到消息 数据长度=>" + data.Length); + //记录接受长度 + mReciveAllLenght += data.Length; + if (!GetSocketIdxBySocket(sk, out int Idx)) + return; + try + { + //抛出网络数据 + AppNoSugarNet.local.OnClientTunnelDataCallBack(mTunnelID, (byte)Idx, data); + } + catch (Exception ex) + { + AppNoSugarNet.log.Info("逻辑处理错误:" + ex.ToString()); + } + } + + public void CloseConnectByIdx(byte Idx) + { + if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInf)) + { + _localClientInf._socket.Shutdown(SocketShutdown.Both); + } + } + + /// + /// 断开连接 + /// + /// + public void OnDisconnect(AsyncUserToken token) + { + AppNoSugarNet.log.Info("断开连接"); + + if (!GetSocketIdxBySocket(token.Socket, out int Idx)) + return; + + AppNoSugarNet.local.OnClientLocalDisconnect(mTunnelID, (byte)Idx); + RemoveDictSocket(token.Socket); + } + + public void OnShowNetLog(string msg) + { + AppNoSugarNet.log.Info(msg); + } + + #region 一个轻量级无用户连接管理 + Dictionary DictSocketHandle2Idx = new Dictionary(); + Dictionary DictIdx2LocalClientInfo = new Dictionary(); + int mSeedIdx = 0; + List FreeIdxs = new List(); + public class LocalClientInfo + { + public Socket _socket; + public bool bRemoteConnect; + public bool bLocalConnect => _socket.Connected; + public Queue msgQueue = new Queue(); + } + + int GetNextIdx() + { + if (FreeIdxs.Count > 0) + { + int Idx = FreeIdxs[0]; + FreeIdxs.RemoveAt(0); + return Idx; + } + return mSeedIdx++; + } + + /// + /// 追加Socket返回下标 + /// + /// + /// + public int AddDictSocket(Socket socket) + { + if (socket == null) + return -1; + lock (DictSocketHandle2Idx) + { + int Idx = GetNextIdx(); + DictSocketHandle2Idx[socket.Handle] = Idx; + DictIdx2LocalClientInfo[Idx] = new LocalClientInfo() { _socket = socket,bRemoteConnect = false}; + return Idx; + } + } + + public void RemoveDictSocket(Socket socket) + { + if (socket == null) + return; + lock (DictSocketHandle2Idx) + { + if (!DictSocketHandle2Idx.ContainsKey(socket.Handle)) + return; + int Idx = DictSocketHandle2Idx[socket.Handle]; + FreeIdxs.Add(Idx); + if (DictIdx2LocalClientInfo.ContainsKey(Idx)) + DictIdx2LocalClientInfo.Remove(Idx); + DictSocketHandle2Idx.Remove(socket.Handle); + } + } + + bool GetSocketByIdx(int Idx, out LocalClientInfo _localClientInfo) + { + if (!DictIdx2LocalClientInfo.ContainsKey(Idx)) + { + _localClientInfo = null; + return false; + } + + _localClientInfo = DictIdx2LocalClientInfo[Idx]; + return true; + } + + public bool GetSocketIdxBySocket(Socket _socket, out int Idx) + { + if (_socket == null) + { + Idx = -1; + return false; + } + + if (!DictSocketHandle2Idx.ContainsKey(_socket.Handle)) + { + Idx = -1; + return false; + } + + Idx = DictSocketHandle2Idx[_socket.Handle]; + return true; + } + + public bool CheckRemoteConnect(int Idx) + { + if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo)) + return false; + return _localClientInfo.bRemoteConnect; + } + + public void SetRemoteConnectd(int Idx,bool bConnected) + { + if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo)) + return; + if (bConnected) + AppNoSugarNet.log.Info("远端本地连接已连接!!!!"); + else + AppNoSugarNet.log.Info("远端本地连接已断开连接!!!!"); + _localClientInfo.bRemoteConnect = bConnected; + } + + public void StopAll() + { + lock (DictIdx2LocalClientInfo) + { + int[] Idxs = DictIdx2LocalClientInfo.Keys.ToArray(); + for (int i = 0; i < Idxs.Length; i++) + { + CloseConnectByIdx((byte)Idxs[i]); + } + DictIdx2LocalClientInfo.Clear(); + } + } + + #endregion + + #region 缓存 + public void EnqueueIdxWithMsg(byte Idx, byte[] data) + { + if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo)) + return; + + IdxWithMsg Msg = AppNoSugarNet.local._localMsgPool.Dequeue(); + Msg.Idx = Idx; + Msg.data = data; + _localClientInfo.msgQueue.Enqueue(Msg); + } + public bool GetDictMsgQueue(byte Idx,out List MsgList) + { + if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo) || _localClientInfo.msgQueue.Count < 1) + { + MsgList = null; + return false; + } + + MsgList = new List(); + lock (_localClientInfo.msgQueue) + { + while (_localClientInfo.msgQueue.Count > 0) + { + IdxWithMsg msg = _localClientInfo.msgQueue.Dequeue(); + MsgList.Add(msg); + } + return true; + } + } + #endregion + } +} diff --git a/NoSugarNet.ClientCore.Standard2/Manager/LocalClient/LocalListener_Source.cs b/NoSugarNet.ClientCore.Standard2/Manager/LocalClient/LocalListener_Source.cs new file mode 100644 index 0000000..57f3da7 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Manager/LocalClient/LocalListener_Source.cs @@ -0,0 +1,292 @@ +using HaoYueNet.ClientNetworkNet.Standard2.OtherMode; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Sockets; + +namespace NoSugarNet.ClientCoreNet.Standard2 +{ + public class LocalListener_Source : NetworkHelperCore_ListenerMode + { + public byte mTunnelID; + public long mReciveAllLenght; + public long mSendAllLenght; + public LocalListener_Source(int numConnections, int receiveBufferSize, byte TunnelID) + : base() + { + OnConnected += ClientNumberChange; + OnReceive += ReceiveData; + OnDisconnected += OnDisconnectClient; + OnNetLog += OnShowNetLog; + + mTunnelID = TunnelID; + } + + private void ClientNumberChange(Socket socket) + { + AppNoSugarNet.log.Info("Client数发生变化"); + //增加连接数 + int Idx = AddDictSocket(socket); + if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInf)) + { + AppNoSugarNet.local.OnClientLocalConnect(mTunnelID, (byte)Idx); + } + } + + /// + /// 通过下标发送 + /// + /// + /// + public void SendSocketByIdx(int Idx, byte[] data) + { + if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo)) + { + mSendAllLenght += data.Length; + SendToClient(_localClientInfo._socket, data); + } + //TODO连接前缓存数据 + } + + /// + /// 接受包回调 + /// + /// 协议ID + /// 错误编号 + /// 业务数据 + private void ReceiveData(Socket sk, byte[] data) + { + DataCallBack(sk, data); + } + + public void DataCallBack(Socket sk, byte[] data) + { + //AppNoSugarNet.log.Info("收到消息 数据长度=>" + data.Length); + //记录接受长度 + mReciveAllLenght += data.Length; + if (!GetSocketIdxBySocket(sk, out int Idx)) + return; + try + { + if (GetMsgQueueByIdx(sk.Handle, out Queue _queue)) + { + lock (_queue) + { + _queue.Enqueue(data); + while (_queue.Count > 0) + { + AppNoSugarNet.local.OnClientTunnelDataCallBack(mTunnelID, (byte)Idx, _queue.Dequeue()); + } + } + } + + ////抛出网络数据 + //AppNoSugarNet.local.OnClientTunnelDataCallBack(mTunnelID, (byte)Idx, data); + } + catch (Exception ex) + { + AppNoSugarNet.log.Info("逻辑处理错误:" + ex.ToString()); + } + } + + public void CloseConnectByIdx(byte Idx) + { + if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInf)) + { + _localClientInf._socket.Shutdown(SocketShutdown.Both); + } + } + + /// + /// 断开连接 + /// + /// + public void OnDisconnectClient(Socket sk) + { + AppNoSugarNet.log.Info("断开连接"); + + if (!GetSocketIdxBySocket(sk, out int Idx)) + return; + + AppNoSugarNet.local.OnClientLocalDisconnect(mTunnelID, (byte)Idx); + RemoveDictSocket(sk); + } + + public void OnShowNetLog(string msg) + { + AppNoSugarNet.log.Info(msg); + } + + #region 一个轻量级无用户连接管理 + Dictionary DictSocketHandle2Idx = new Dictionary(); + Dictionary> DictSocketHandle2Msg = new Dictionary>(); + Dictionary DictIdx2LocalClientInfo = new Dictionary(); + int mSeedIdx = 0; + List FreeIdxs = new List(); + public class LocalClientInfo + { + public Socket _socket; + public bool bRemoteConnect; + public bool bLocalConnect => _socket.Connected; + public Queue msgQueue = new Queue(); + } + + int GetNextIdx() + { + if (FreeIdxs.Count > 0) + { + int Idx = FreeIdxs[0]; + FreeIdxs.RemoveAt(0); + return Idx; + } + return mSeedIdx++; + } + + /// + /// 追加Socket返回下标 + /// + /// + /// + public int AddDictSocket(Socket socket) + { + if (socket == null) + return -1; + lock (DictSocketHandle2Idx) + { + int Idx = GetNextIdx(); + DictSocketHandle2Idx[socket.Handle] = Idx; + DictIdx2LocalClientInfo[Idx] = new LocalClientInfo() { _socket = socket,bRemoteConnect = false}; + DictSocketHandle2Msg[socket.Handle] = new Queue(); + return Idx; + } + } + + public void RemoveDictSocket(Socket socket) + { + if (socket == null) + return; + lock (DictSocketHandle2Idx) + { + if (!DictSocketHandle2Idx.ContainsKey(socket.Handle)) + return; + int Idx = DictSocketHandle2Idx[socket.Handle]; + FreeIdxs.Add(Idx); + if (DictIdx2LocalClientInfo.ContainsKey(Idx)) + DictIdx2LocalClientInfo.Remove(Idx); + + if (DictSocketHandle2Msg.ContainsKey(socket.Handle)) + DictSocketHandle2Msg.Remove(socket.Handle); + + DictSocketHandle2Idx.Remove(socket.Handle); + } + } + + bool GetSocketByIdx(int Idx, out LocalClientInfo _localClientInfo) + { + if (!DictIdx2LocalClientInfo.ContainsKey(Idx)) + { + _localClientInfo = null; + return false; + } + + _localClientInfo = DictIdx2LocalClientInfo[Idx]; + return true; + } + + bool GetMsgQueueByIdx(IntPtr handle, out Queue _queue) + { + if (!DictSocketHandle2Msg.ContainsKey(handle)) + { + _queue = null; + return false; + } + + _queue = DictSocketHandle2Msg[handle]; + return true; + } + + public bool GetSocketIdxBySocket(Socket _socket, out int Idx) + { + if (_socket == null) + { + Idx = -1; + return false; + } + + if (!DictSocketHandle2Idx.ContainsKey(_socket.Handle)) + { + Idx = -1; + return false; + } + + Idx = DictSocketHandle2Idx[_socket.Handle]; + return true; + } + + public bool CheckRemoteConnect(int Idx) + { + if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo)) + return false; + return _localClientInfo.bRemoteConnect; + } + + public void SetRemoteConnectd(int Idx,bool bConnected) + { + if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo)) + return; + if (bConnected) + AppNoSugarNet.log.Info("远端本地连接已连接!!!!"); + else + AppNoSugarNet.log.Info("远端本地连接已断开连接!!!!"); + _localClientInfo.bRemoteConnect = bConnected; + } + + public void StopAll() + { + lock (DictIdx2LocalClientInfo) + { + int[] Idxs = DictIdx2LocalClientInfo.Keys.ToArray(); + for (int i = 0; i < Idxs.Length; i++) + { + CloseConnectByIdx((byte)Idxs[i]); + } + DictIdx2LocalClientInfo.Clear(); + } + } + + #endregion + + + #region 缓存 + public void EnqueueIdxWithMsg(byte Idx, byte[] data) + { + if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo)) + return; + + IdxWithMsg Msg = AppNoSugarNet.local._localMsgPool.Dequeue(); + Msg.Idx = Idx; + Msg.data = data; + _localClientInfo.msgQueue.Enqueue(Msg); + } + public bool GetDictMsgQueue(byte Idx,out List MsgList) + { + if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo) || _localClientInfo.msgQueue.Count < 1) + { + MsgList = null; + return false; + } + + MsgList = new List(); + lock (_localClientInfo.msgQueue) + { + while (_localClientInfo.msgQueue.Count > 0) + { + IdxWithMsg msg = _localClientInfo.msgQueue.Dequeue(); + MsgList.Add(msg); + } + return true; + } + } + #endregion + } +} diff --git a/NoSugarNet.ClientCore.Standard2/Manager/LocalClient/LocalMsgQueuePool.cs b/NoSugarNet.ClientCore.Standard2/Manager/LocalClient/LocalMsgQueuePool.cs new file mode 100644 index 0000000..9201ee4 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Manager/LocalClient/LocalMsgQueuePool.cs @@ -0,0 +1,55 @@ +using System.Collections.Generic; + +namespace NoSugarNet.ClientCoreNet.Standard2 +{ + public class IdxWithMsg + { + public byte Idx; + public byte[] data; + } + + public class LocalMsgQueuePool + { + Queue msg_pool; + + public LocalMsgQueuePool(int capacity) + { + msg_pool = new Queue(capacity); + } + + /// + /// 向 Queue 的末尾添加一个对象。 + /// + /// + public void Enqueue(IdxWithMsg item) + { + lock (msg_pool) + { + item.Idx = 0; + item.data = null; + msg_pool.Enqueue(item); + } + } + + //移除并返回在 Queue 的开头的对象。 + public IdxWithMsg Dequeue() + { + lock (msg_pool) + { + if(msg_pool.Count > 0) + return msg_pool.Dequeue(); + return new IdxWithMsg(); + } + } + + public int Count + { + get { return msg_pool.Count; } + } + + public void Clear() + { + msg_pool.Clear(); + } + } +} diff --git a/NoSugarNet.ClientCore.Standard2/Manager/LogManager.cs b/NoSugarNet.ClientCore.Standard2/Manager/LogManager.cs new file mode 100644 index 0000000..e309b0a --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Manager/LogManager.cs @@ -0,0 +1,48 @@ +namespace NoSugarNet.ClientCoreNet.Standard2.Manager +{ + public class LogManager + { + public enum E_LogType:byte + { + Info = 0, + Debug = 1, + Warning = 2, + Error = 3, + } + /// + /// 日志 + /// + /// + public delegate void OnLogHandler(int debuglv,string msg); + + /// + /// 内部输出 + /// + public static event OnLogHandler OnLog; + + public void Info(string str) + { + Log(E_LogType.Info, str); + } + + public void Debug(string str) + { + Log(E_LogType.Debug, str); + } + + public void Warning(string str) + { + Log(E_LogType.Warning, str); + } + + public void Error(string str) + { + Log(E_LogType.Error, str); + } + + public void Log(E_LogType logtype,string str) + { + OnLog?.Invoke((int)logtype, str); + } + } +} \ No newline at end of file diff --git a/NoSugarNet.ClientCore.Standard2/Manager/UserDataManager.cs b/NoSugarNet.ClientCore.Standard2/Manager/UserDataManager.cs new file mode 100644 index 0000000..cf95c10 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Manager/UserDataManager.cs @@ -0,0 +1,56 @@ +using AxibugProtobuf; + +namespace NoSugarNet.ClientCoreNet.Standard2.Manager +{ + public class UserDataBase + { + public long UID { get; set; } + public string Account { get; set; } + } + + public class MainUserDataBase : UserDataBase + { + public bool IsLoggedIn { get; set; } = false; + } + + public class UserDataManager + { + public UserDataManager() + { + //注册重连成功事件,以便后续自动登录 + AppNoSugarNet.networkHelper.OnReConnected += OnReConnected; + } + public MainUserDataBase userdata { get;private set; } = new MainUserDataBase(); + public bool IsLoggedIn => userdata.IsLoggedIn; + + public void InitMainUserData(string UName) + { + userdata.Account = UName; + userdata.IsLoggedIn = true; + //以及其他数据初始化 + //... + } + + /// + /// 登出 + /// + public void LoginOutData() + { + userdata.IsLoggedIn = false; + //以及其他数据清理 + //... + } + + /// + /// 当重连成功 + /// + public void OnReConnected() + { + //如果之前已登录,则重新登录 + if (userdata.IsLoggedIn) + { + AppNoSugarNet.login.Login(userdata.Account); + } + } + } +} diff --git a/NoSugarNet.ClientCore.Standard2/NetStatus.cs b/NoSugarNet.ClientCore.Standard2/NetStatus.cs new file mode 100644 index 0000000..95392de --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/NetStatus.cs @@ -0,0 +1,16 @@ +namespace NoSugarNet.ClientCoreNet.Standard2 +{ + public struct NetStatus + { + public int ClientUserCount; + public int TunnelCount; + public long srcReciveAllLenght; + public long srcSendAllLenght; + public long srcReciveSecSpeed; + public long srcSendSecSpeed; + public long tReciveAllLenght; + public long tSendAllLenght; + public long tReciveSecSpeed; + public long tSendSecSpeed; + } +} diff --git a/NoSugarNet.ClientCore.Standard2/Network/NetMsg.cs b/NoSugarNet.ClientCore.Standard2/Network/NetMsg.cs new file mode 100644 index 0000000..101b5a0 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Network/NetMsg.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; + +namespace NoSugarNet.ClientCoreNet.Standard2.Network +{ + + public class NetMsg + { + private static NetMsg instance = new NetMsg(); + public static NetMsg Instance { get { return instance; } } + + private Dictionary> netEventDic = new Dictionary>(128); + + private NetMsg() { } + + + #region RegisterMsgEvent + + public void RegNetMsgEvent(int cmd, Action callback) + { + InterRegNetMsgEvent(cmd, callback); + } + + private void InterRegNetMsgEvent(int cmd, Delegate callback) + { + if (netEventDic.ContainsKey(cmd)) + { + if (netEventDic[cmd].IndexOf(callback) < 0) + { + netEventDic[cmd].Add(callback); + } + } + else + { + netEventDic.Add(cmd, new List() { callback }); + } + } + #endregion + + #region UnregisterCMD + + public void UnregisterCMD(int evt, Action callback) + { + Delegate tempDelegate = callback; + InterUnregisterCMD(evt, tempDelegate); + } + + private void InterUnregisterCMD(int cmd, Delegate callback) + { + if (netEventDic.ContainsKey(cmd)) + { + netEventDic[cmd].Remove(callback); + if (netEventDic[cmd].Count == 0) netEventDic.Remove(cmd); + } + } + #endregion + + #region PostEvent + public void PostNetMsgEvent(int cmd, byte[] arg) + { + List eventList = GetNetEventDicList(cmd); + if (eventList != null) + { + foreach (Delegate callback in eventList) + { + try + { + ((Action)callback)(arg); + } + catch (Exception e) + { + AppNoSugarNet.log.Error(e.Message); + } + } + } + } + #endregion + + /// + /// 获取所有事件 + /// + /// + /// + private List GetNetEventDicList(int cmd) + { + if (netEventDic.ContainsKey(cmd)) + { + List tempList = netEventDic[cmd]; + if (null != tempList) + { + return tempList; + } + } + return null; + } + } +} diff --git a/NoSugarNet.ClientCore.Standard2/Network/NetworkHelper.cs b/NoSugarNet.ClientCore.Standard2/Network/NetworkHelper.cs new file mode 100644 index 0000000..0a1c387 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Network/NetworkHelper.cs @@ -0,0 +1,125 @@ +using HaoYueNet.ClientNetworkNet.Standard2; +using System; +using System.Threading; + +namespace NoSugarNet.ClientCoreNet.Standard2.Network +{ + /// + /// 继承网络库,以支持网络功能 + /// + public class NetworkHelper : NetworkHelperCore + { + public NetworkHelper() + { + //指定接收服务器数据事件 + OnReceiveData += GetDataCallBack; + //断开连接 + OnClose += OnConnectClose; + OnConnected += NetworkConnected; + //网络库调试信息输出事件,用于打印网络内容 + OnLogOut += NetworkDeBugLog; + } + + public delegate void OnReConnectedHandler(); + /// + /// 重连成功事件 + /// + public event OnReConnectedHandler OnReConnected; + /// + /// 是否自动重连 + /// + public bool bAutoReConnect = false; + /// + /// 重连尝试时间 + /// + const int ReConnectTryTime = 1000; + + public void NetworkConnected(bool IsConnect) + { + NetworkDeBugLog($"NetworkConnected:{IsConnect}"); + if (IsConnect) + { + AppNoSugarNet.login.Login(Guid.NewGuid().ToString()); + } + else + { + //连接失败 + NetworkDeBugLog("连接失败!"); + //自动重连开关 + if (bAutoReConnect) + ReConnect(); + } + } + + public void NetworkDeBugLog(string str) + { + //用于Unity内的输出 + //Debug.Log("NetCoreDebug >> "+str); + AppNoSugarNet.log.Info("NetCoreDebug >> " + str); + } + + /// + /// 接受包回调 + /// + /// 协议ID + /// 错误编号 + /// 业务数据 + public void GetDataCallBack(int CMDID, int ERRCODE, byte[] data) + { + //NetworkDeBugLog("收到消息 CMDID =>" + CMDID + " ERRCODE =>" + ERRCODE + " 数据长度=>" + data.Length); + try + { + //抛出网络数据 + NetMsg.Instance.PostNetMsgEvent(CMDID, data); + } + catch (Exception ex) + { + NetworkDeBugLog("逻辑处理错误:" + ex.ToString()); + } + } + + /// + /// 关闭连接 + /// + public void OnConnectClose() + { + NetworkDeBugLog("OnConnectClose"); + + //停止所有 + AppNoSugarNet.local.StopAll(); + + //自动重连开关 + if (bAutoReConnect) + ReConnect(); + } + + + bool bInReConnecting = false; + /// + /// 自动重连 + /// + void ReConnect() + { + if (bInReConnecting) + return; + bInReConnecting = true; + + bool bflagDone = false; + do + { + //等待时间 + Thread.Sleep(ReConnectTryTime); + AppNoSugarNet.log.Info($"尝试自动重连{LastConnectIP}:{LastConnectPort}……"); + //第一步 + if (Init(LastConnectIP, LastConnectPort)) + { + AppNoSugarNet.log.Info($"自动重连成功!"); + bflagDone = true; + AppNoSugarNet.log.Info($"触发重连后的自动逻辑!"); + OnReConnected?.Invoke(); + } + } while (!bflagDone); + bInReConnecting = false; + } + } +} diff --git a/NoSugarNet.ClientCore.Standard2/NoSugarNet.ClientCore.Standard2.csproj b/NoSugarNet.ClientCore.Standard2/NoSugarNet.ClientCore.Standard2.csproj new file mode 100644 index 0000000..46ead48 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/NoSugarNet.ClientCore.Standard2.csproj @@ -0,0 +1,26 @@ + + + netstandard2.0 + + + + 8.0 + + + + + + + ..\Lib\Google.Protobuf.dll + + + ..\Lib\NetLib_Standard2\HaoYueNet.ClientNetworkNet.Standard2.dll + + + ..\Lib\NetLib_Standard2\HaoYueNet.ServerNetwork.Standard2.dll + + + ..\Lib\NetLib_Standard2\NoSugarNet.DataHelper.dll + + + \ No newline at end of file diff --git a/NoSugarNet.ClientCore.Standard2/NoSugarNet.ClientCore.Standard2.csproj.user b/NoSugarNet.ClientCore.Standard2/NoSugarNet.ClientCore.Standard2.csproj.user new file mode 100644 index 0000000..33c4ad6 --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/NoSugarNet.ClientCore.Standard2.csproj.user @@ -0,0 +1,6 @@ + + + + <_LastSelectedProfileId>F:\Sin365\NoSugarNet\NoSugarNet.ClientCore.Standard2\Properties\PublishProfiles\FolderProfile.pubxml + + \ No newline at end of file diff --git a/NoSugarNet.ClientCore.Standard2/Properties/PublishProfiles/FolderProfile.pubxml b/NoSugarNet.ClientCore.Standard2/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000..659e1ee --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,13 @@ + + + + + Release + Any CPU + bin\Release\netstandard2.0\publish\ + FileSystem + <_TargetId>Folder + + \ No newline at end of file diff --git a/NoSugarNet.ClientCore.Standard2/Properties/PublishProfiles/FolderProfile.pubxml.user b/NoSugarNet.ClientCore.Standard2/Properties/PublishProfiles/FolderProfile.pubxml.user new file mode 100644 index 0000000..040aa3b --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -0,0 +1,10 @@ + + + + + True|2024-04-15T06:51:39.2435225Z;True|2024-04-15T14:51:19.4250865+08:00;True|2024-04-15T14:49:22.9829361+08:00; + + + \ No newline at end of file diff --git a/NoSugarNet.ClientCore.Standard2/Protobuf/ProtobufNoSugar.cs b/NoSugarNet.ClientCore.Standard2/Protobuf/ProtobufNoSugar.cs new file mode 100644 index 0000000..dce38be --- /dev/null +++ b/NoSugarNet.ClientCore.Standard2/Protobuf/ProtobufNoSugar.cs @@ -0,0 +1,3012 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: protobuf_NoSugar.proto +// +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace AxibugProtobuf { + + /// Holder for reflection information generated from protobuf_NoSugar.proto + public static partial class ProtobufNoSugarReflection { + + #region Descriptor + /// File descriptor for protobuf_NoSugar.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ProtobufNoSugarReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChZwcm90b2J1Zl9Ob1N1Z2FyLnByb3RvEg5BeGlidWdQcm90b2J1ZiKRAQoO", + "UHJvdG9idWZfTG9naW4SLAoJbG9naW5UeXBlGAEgASgOMhkuQXhpYnVnUHJv", + "dG9idWYuTG9naW5UeXBlEi4KCmRldmljZVR5cGUYAiABKA4yGi5BeGlidWdQ", + "cm90b2J1Zi5EZXZpY2VUeXBlEg8KB0FjY291bnQYAyABKAkSEAoIUGFzc3dv", + "cmQYBCABKAkifwoTUHJvdG9idWZfTG9naW5fUkVTUBINCgVUb2tlbhgBIAEo", + "CRIVCg1MYXN0TG9naW5EYXRlGAIgASgJEg8KB1JlZ0RhdGUYAyABKAkSMQoG", + "U3RhdHVzGAQgASgOMiEuQXhpYnVnUHJvdG9idWYuTG9naW5SZXN1bHRTdGF0", + "dXMiYAoNUHJvdG9idWZfQ2ZncxIbChNDb21wcmVzc0FkYXB0ZXJUeXBlGAEg", + "ASgFEjIKBGNmZ3MYAiADKAsyJC5BeGlidWdQcm90b2J1Zi5Qcm90b2J1Zl9D", + "ZmdzX1NpbmdsZSI2ChRQcm90b2J1Zl9DZmdzX1NpbmdsZRIQCghUdW5uZWxJ", + "RBgBIAEoDRIMCgRQb3J0GAIgASgFIiMKEFByb3RvYnVmX0NoYXRNc2cSDwoH", + "Q2hhdE1zZxgBIAEoCSJIChVQcm90b2J1Zl9DaGF0TXNnX1JFU1ASEAoITmlj", + "a05hbWUYASABKAkSDwoHQ2hhdE1zZxgCIAEoCRIMCgREYXRlGAMgASgDIjUK", + "FFByb3RvYnVmX0MyU19Db25uZWN0EhAKCFR1bm5lbElEGAEgASgNEgsKA0lk", + "eBgCIAEoDSJIChRQcm90b2J1Zl9TMkNfQ29ubmVjdBIQCghUdW5uZWxJRBgB", + "IAEoDRILCgNJZHgYAiABKA0SEQoJQ29ubmVjdGVkGAMgASgNIjgKF1Byb3Rv", + "YnVmX0MyU19EaXNjb25uZWN0EhAKCFR1bm5lbElEGAEgASgNEgsKA0lkeBgC", + "IAEoDSI4ChdQcm90b2J1Zl9TMkNfRGlzY29ubmVjdBIQCghUdW5uZWxJRBgB", + "IAEoDRILCgNJZHgYAiABKA0iTgoRUHJvdG9idWZfQzJTX0RBVEESEAoIVHVu", + "bmVsSUQYASABKA0SCwoDSWR4GAIgASgNEhoKEkh1bnRlck5ldENvcmVfRGF0", + "YRgDIAEoDCJOChFQcm90b2J1Zl9TMkNfREFUQRIQCghUdW5uZWxJRBgBIAEo", + "DRILCgNJZHgYAiABKA0SGgoSSHVudGVyTmV0Q29yZV9EYXRhGAMgASgMKvoB", + "CglDb21tYW5kSUQSDgoKQ01EX0RFRkFVTBAAEg4KCUNNRF9MT0dJThDRDxIN", + "CghDTURfQ0ZHUxC5FxIQCgtDTURfQ0hBVE1TRxChHxIbChZDTURfVFVOTkVM", + "X0MyU19DT05ORUNUEIgnEhsKFkNNRF9UVU5ORUxfUzJDX0NPTk5FQ1QQiScS", + "HgoZQ01EX1RVTk5FTF9DMlNfRElTQ09OTkVDVBCKJxIeChlDTURfVFVOTkVM", + "X1MyQ19ESVNDT05ORUNUEIsnEhgKE0NNRF9UVU5ORUxfQzJTX0RBVEEQjCcS", + "GAoTQ01EX1RVTk5FTF9TMkNfREFUQRCNJyorCglFcnJvckNvZGUSEAoMRVJS", + "T1JfREVGQVVMEAASDAoIRVJST1JfT0sQASo+CglMb2dpblR5cGUSDwoLQmFz", + "ZURlZmF1bHQQABIOCgpIYW9ZdWVBdXRoEAESBwoDQkYzEAMSBwoDQkY0EAQq", + "SwoKRGV2aWNlVHlwZRIWChJEZXZpY2VUeXBlX0RlZmF1bHQQABIGCgJQQxAB", + "EgsKB0FuZHJvaWQQAhIHCgNJT1MQAxIHCgNQU1YQBCpOChFMb2dpblJlc3Vs", + "dFN0YXR1cxIhCh1Mb2dpblJlc3VsdFN0YXR1c19CYXNlRGVmYXVsdBAAEgYK", + "Ak9LEAESDgoKQWNjb3VudEVychACQgJIAWIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::AxibugProtobuf.CommandID), typeof(global::AxibugProtobuf.ErrorCode), typeof(global::AxibugProtobuf.LoginType), typeof(global::AxibugProtobuf.DeviceType), typeof(global::AxibugProtobuf.LoginResultStatus), }, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login), global::AxibugProtobuf.Protobuf_Login.Parser, new[]{ "LoginType", "DeviceType", "Account", "Password" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Cfgs), global::AxibugProtobuf.Protobuf_Cfgs.Parser, new[]{ "CompressAdapterType", "Cfgs" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Cfgs_Single), global::AxibugProtobuf.Protobuf_Cfgs_Single.Parser, new[]{ "TunnelID", "Port" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg), global::AxibugProtobuf.Protobuf_ChatMsg.Parser, new[]{ "ChatMsg" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg_RESP), global::AxibugProtobuf.Protobuf_ChatMsg_RESP.Parser, new[]{ "NickName", "ChatMsg", "Date" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_C2S_Connect), global::AxibugProtobuf.Protobuf_C2S_Connect.Parser, new[]{ "TunnelID", "Idx" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_S2C_Connect), global::AxibugProtobuf.Protobuf_S2C_Connect.Parser, new[]{ "TunnelID", "Idx", "Connected" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_C2S_Disconnect), global::AxibugProtobuf.Protobuf_C2S_Disconnect.Parser, new[]{ "TunnelID", "Idx" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_S2C_Disconnect), global::AxibugProtobuf.Protobuf_S2C_Disconnect.Parser, new[]{ "TunnelID", "Idx" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_C2S_DATA), global::AxibugProtobuf.Protobuf_C2S_DATA.Parser, new[]{ "TunnelID", "Idx", "HunterNetCoreData" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_S2C_DATA), global::AxibugProtobuf.Protobuf_S2C_DATA.Parser, new[]{ "TunnelID", "Idx", "HunterNetCoreData" }, null, null, null, null) + })); + } + #endregion + + } + #region Enums + public enum CommandID { + /// + ///缺省不使用 + /// + [pbr::OriginalName("CMD_DEFAUL")] CmdDefaul = 0, + /// + ///自动登录上行 | 下行 对应 Protobuf_Login | Protobuf_Login_RESP + /// + [pbr::OriginalName("CMD_LOGIN")] CmdLogin = 2001, + /// + ///配置信息 下行 对应 Protobuf_Cfgs + /// + [pbr::OriginalName("CMD_CFGS")] CmdCfgs = 3001, + /// + ///广播信息上行 | 下行 对应 Protobuf_ChatMsg | Protobuf_ChatMsg_RESP + /// + [pbr::OriginalName("CMD_CHATMSG")] CmdChatmsg = 4001, + /// + ///客户端告知服务端 客户端本地连接建立 上行 Protobuf_C2S_Connect + /// + [pbr::OriginalName("CMD_TUNNEL_C2S_CONNECT")] CmdTunnelC2SConnect = 5000, + /// + ///服务端告知客户端 服务端本地连接建立 下行 Protobuf_S2C_Connect + /// + [pbr::OriginalName("CMD_TUNNEL_S2C_CONNECT")] CmdTunnelS2CConnect = 5001, + /// + ///客户端告知服务端 客户端本地连接断开 上行 Protobuf_C2S_Disconnect + /// + [pbr::OriginalName("CMD_TUNNEL_C2S_DISCONNECT")] CmdTunnelC2SDisconnect = 5002, + /// + ///服务端告知客户端 服务端本地连接断开 下行 Protobuf_S2C_Disconnect + /// + [pbr::OriginalName("CMD_TUNNEL_S2C_DISCONNECT")] CmdTunnelS2CDisconnect = 5003, + /// + ///客户端投递本地TCP通讯数据包 上行 Protobuf_C2S_DATA + /// + [pbr::OriginalName("CMD_TUNNEL_C2S_DATA")] CmdTunnelC2SData = 5004, + /// + ///服务端投递本地TCP通讯数据包 下行 Protobuf_S2C_DATA + /// + [pbr::OriginalName("CMD_TUNNEL_S2C_DATA")] CmdTunnelS2CData = 5005, + } + + public enum ErrorCode { + /// + ///缺省不使用 + /// + [pbr::OriginalName("ERROR_DEFAUL")] ErrorDefaul = 0, + /// + ///成功 + /// + [pbr::OriginalName("ERROR_OK")] ErrorOk = 1, + } + + public enum LoginType { + /// + ///缺省不使用 + /// + [pbr::OriginalName("BaseDefault")] BaseDefault = 0, + [pbr::OriginalName("HaoYueAuth")] HaoYueAuth = 1, + [pbr::OriginalName("BF3")] Bf3 = 3, + [pbr::OriginalName("BF4")] Bf4 = 4, + } + + public enum DeviceType { + /// + ///缺省不使用 + /// + [pbr::OriginalName("DeviceType_Default")] Default = 0, + [pbr::OriginalName("PC")] Pc = 1, + [pbr::OriginalName("Android")] Android = 2, + [pbr::OriginalName("IOS")] Ios = 3, + [pbr::OriginalName("PSV")] Psv = 4, + } + + public enum LoginResultStatus { + /// + ///缺省不使用 + /// + [pbr::OriginalName("LoginResultStatus_BaseDefault")] BaseDefault = 0, + [pbr::OriginalName("OK")] Ok = 1, + [pbr::OriginalName("AccountErr")] AccountErr = 2, + } + + #endregion + + #region Messages + /// + ///登录数据上行 + /// + public sealed partial class Protobuf_Login : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_Login()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufNoSugarReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_Login() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_Login(Protobuf_Login other) : this() { + loginType_ = other.loginType_; + deviceType_ = other.deviceType_; + account_ = other.account_; + password_ = other.password_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_Login Clone() { + return new Protobuf_Login(this); + } + + /// Field number for the "loginType" field. + public const int LoginTypeFieldNumber = 1; + private global::AxibugProtobuf.LoginType loginType_ = global::AxibugProtobuf.LoginType.BaseDefault; + /// + ///登录操作类型 [0]皓月通行证 [3] 皓月BF3 [4] 皓月BF4 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::AxibugProtobuf.LoginType LoginType { + get { return loginType_; } + set { + loginType_ = value; + } + } + + /// Field number for the "deviceType" field. + public const int DeviceTypeFieldNumber = 2; + private global::AxibugProtobuf.DeviceType deviceType_ = global::AxibugProtobuf.DeviceType.Default; + /// + ///设备类型 [0]PC [1]AndroidPad预留 [3]IPad预留 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::AxibugProtobuf.DeviceType DeviceType { + get { return deviceType_; } + set { + deviceType_ = value; + } + } + + /// Field number for the "Account" field. + public const int AccountFieldNumber = 3; + private string account_ = ""; + /// + ///用户名 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Account { + get { return account_; } + set { + account_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "Password" field. + public const int PasswordFieldNumber = 4; + private string password_ = ""; + /// + ///密码 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Password { + get { return password_; } + set { + password_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_Login); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_Login other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (LoginType != other.LoginType) return false; + if (DeviceType != other.DeviceType) return false; + if (Account != other.Account) return false; + if (Password != other.Password) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (LoginType != global::AxibugProtobuf.LoginType.BaseDefault) hash ^= LoginType.GetHashCode(); + if (DeviceType != global::AxibugProtobuf.DeviceType.Default) hash ^= DeviceType.GetHashCode(); + if (Account.Length != 0) hash ^= Account.GetHashCode(); + if (Password.Length != 0) hash ^= Password.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (LoginType != global::AxibugProtobuf.LoginType.BaseDefault) { + output.WriteRawTag(8); + output.WriteEnum((int) LoginType); + } + if (DeviceType != global::AxibugProtobuf.DeviceType.Default) { + output.WriteRawTag(16); + output.WriteEnum((int) DeviceType); + } + if (Account.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Account); + } + if (Password.Length != 0) { + output.WriteRawTag(34); + output.WriteString(Password); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (LoginType != global::AxibugProtobuf.LoginType.BaseDefault) { + output.WriteRawTag(8); + output.WriteEnum((int) LoginType); + } + if (DeviceType != global::AxibugProtobuf.DeviceType.Default) { + output.WriteRawTag(16); + output.WriteEnum((int) DeviceType); + } + if (Account.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Account); + } + if (Password.Length != 0) { + output.WriteRawTag(34); + output.WriteString(Password); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (LoginType != global::AxibugProtobuf.LoginType.BaseDefault) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) LoginType); + } + if (DeviceType != global::AxibugProtobuf.DeviceType.Default) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) DeviceType); + } + if (Account.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Account); + } + if (Password.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Password); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_Login other) { + if (other == null) { + return; + } + if (other.LoginType != global::AxibugProtobuf.LoginType.BaseDefault) { + LoginType = other.LoginType; + } + if (other.DeviceType != global::AxibugProtobuf.DeviceType.Default) { + DeviceType = other.DeviceType; + } + if (other.Account.Length != 0) { + Account = other.Account; + } + if (other.Password.Length != 0) { + Password = other.Password; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + LoginType = (global::AxibugProtobuf.LoginType) input.ReadEnum(); + break; + } + case 16: { + DeviceType = (global::AxibugProtobuf.DeviceType) input.ReadEnum(); + break; + } + case 26: { + Account = input.ReadString(); + break; + } + case 34: { + Password = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + LoginType = (global::AxibugProtobuf.LoginType) input.ReadEnum(); + break; + } + case 16: { + DeviceType = (global::AxibugProtobuf.DeviceType) input.ReadEnum(); + break; + } + case 26: { + Account = input.ReadString(); + break; + } + case 34: { + Password = input.ReadString(); + break; + } + } + } + } + #endif + + } + + /// + ///登录数据下行 + /// + public sealed partial class Protobuf_Login_RESP : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_Login_RESP()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufNoSugarReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_Login_RESP() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_Login_RESP(Protobuf_Login_RESP other) : this() { + token_ = other.token_; + lastLoginDate_ = other.lastLoginDate_; + regDate_ = other.regDate_; + status_ = other.status_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_Login_RESP Clone() { + return new Protobuf_Login_RESP(this); + } + + /// Field number for the "Token" field. + public const int TokenFieldNumber = 1; + private string token_ = ""; + /// + ///登录凭据 (本次登录之后,所有业务请求凭据,需要存储在内存中) + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Token { + get { return token_; } + set { + token_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "LastLoginDate" field. + public const int LastLoginDateFieldNumber = 2; + private string lastLoginDate_ = ""; + /// + ///上次登录时间(只用于呈现的字符串,若界面需求需要) + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string LastLoginDate { + get { return lastLoginDate_; } + set { + lastLoginDate_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "RegDate" field. + public const int RegDateFieldNumber = 3; + private string regDate_ = ""; + /// + ///注册时间(只用于呈现的字符串,若界面需求需要) + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string RegDate { + get { return regDate_; } + set { + regDate_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "Status" field. + public const int StatusFieldNumber = 4; + private global::AxibugProtobuf.LoginResultStatus status_ = global::AxibugProtobuf.LoginResultStatus.BaseDefault; + /// + ///账号状态 (预留) [1]正常[0]被禁封 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::AxibugProtobuf.LoginResultStatus Status { + get { return status_; } + set { + status_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_Login_RESP); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_Login_RESP other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Token != other.Token) return false; + if (LastLoginDate != other.LastLoginDate) return false; + if (RegDate != other.RegDate) return false; + if (Status != other.Status) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Token.Length != 0) hash ^= Token.GetHashCode(); + if (LastLoginDate.Length != 0) hash ^= LastLoginDate.GetHashCode(); + if (RegDate.Length != 0) hash ^= RegDate.GetHashCode(); + if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) hash ^= Status.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (Token.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Token); + } + if (LastLoginDate.Length != 0) { + output.WriteRawTag(18); + output.WriteString(LastLoginDate); + } + if (RegDate.Length != 0) { + output.WriteRawTag(26); + output.WriteString(RegDate); + } + if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) { + output.WriteRawTag(32); + output.WriteEnum((int) Status); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (Token.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Token); + } + if (LastLoginDate.Length != 0) { + output.WriteRawTag(18); + output.WriteString(LastLoginDate); + } + if (RegDate.Length != 0) { + output.WriteRawTag(26); + output.WriteString(RegDate); + } + if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) { + output.WriteRawTag(32); + output.WriteEnum((int) Status); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Token.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Token); + } + if (LastLoginDate.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(LastLoginDate); + } + if (RegDate.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(RegDate); + } + if (Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Status); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_Login_RESP other) { + if (other == null) { + return; + } + if (other.Token.Length != 0) { + Token = other.Token; + } + if (other.LastLoginDate.Length != 0) { + LastLoginDate = other.LastLoginDate; + } + if (other.RegDate.Length != 0) { + RegDate = other.RegDate; + } + if (other.Status != global::AxibugProtobuf.LoginResultStatus.BaseDefault) { + Status = other.Status; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + Token = input.ReadString(); + break; + } + case 18: { + LastLoginDate = input.ReadString(); + break; + } + case 26: { + RegDate = input.ReadString(); + break; + } + case 32: { + Status = (global::AxibugProtobuf.LoginResultStatus) input.ReadEnum(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + Token = input.ReadString(); + break; + } + case 18: { + LastLoginDate = input.ReadString(); + break; + } + case 26: { + RegDate = input.ReadString(); + break; + } + case 32: { + Status = (global::AxibugProtobuf.LoginResultStatus) input.ReadEnum(); + break; + } + } + } + } + #endif + + } + + /// + ///配置下行 + /// + public sealed partial class Protobuf_Cfgs : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_Cfgs()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufNoSugarReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_Cfgs() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_Cfgs(Protobuf_Cfgs other) : this() { + compressAdapterType_ = other.compressAdapterType_; + cfgs_ = other.cfgs_.Clone(); + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_Cfgs Clone() { + return new Protobuf_Cfgs(this); + } + + /// Field number for the "CompressAdapterType" field. + public const int CompressAdapterTypeFieldNumber = 1; + private int compressAdapterType_; + /// + ///压缩类型 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CompressAdapterType { + get { return compressAdapterType_; } + set { + compressAdapterType_ = value; + } + } + + /// Field number for the "cfgs" field. + public const int CfgsFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_cfgs_codec + = pb::FieldCodec.ForMessage(18, global::AxibugProtobuf.Protobuf_Cfgs_Single.Parser); + private readonly pbc::RepeatedField cfgs_ = new pbc::RepeatedField(); + /// + ///配置 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Cfgs { + get { return cfgs_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_Cfgs); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_Cfgs other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (CompressAdapterType != other.CompressAdapterType) return false; + if(!cfgs_.Equals(other.cfgs_)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (CompressAdapterType != 0) hash ^= CompressAdapterType.GetHashCode(); + hash ^= cfgs_.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (CompressAdapterType != 0) { + output.WriteRawTag(8); + output.WriteInt32(CompressAdapterType); + } + cfgs_.WriteTo(output, _repeated_cfgs_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (CompressAdapterType != 0) { + output.WriteRawTag(8); + output.WriteInt32(CompressAdapterType); + } + cfgs_.WriteTo(ref output, _repeated_cfgs_codec); + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (CompressAdapterType != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(CompressAdapterType); + } + size += cfgs_.CalculateSize(_repeated_cfgs_codec); + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_Cfgs other) { + if (other == null) { + return; + } + if (other.CompressAdapterType != 0) { + CompressAdapterType = other.CompressAdapterType; + } + cfgs_.Add(other.cfgs_); + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + CompressAdapterType = input.ReadInt32(); + break; + } + case 18: { + cfgs_.AddEntriesFrom(input, _repeated_cfgs_codec); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + CompressAdapterType = input.ReadInt32(); + break; + } + case 18: { + cfgs_.AddEntriesFrom(ref input, _repeated_cfgs_codec); + break; + } + } + } + } + #endif + + } + + public sealed partial class Protobuf_Cfgs_Single : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_Cfgs_Single()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufNoSugarReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_Cfgs_Single() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_Cfgs_Single(Protobuf_Cfgs_Single other) : this() { + tunnelID_ = other.tunnelID_; + port_ = other.port_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_Cfgs_Single Clone() { + return new Protobuf_Cfgs_Single(this); + } + + /// Field number for the "TunnelID" field. + public const int TunnelIDFieldNumber = 1; + private uint tunnelID_; + /// + ///TunnelID + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint TunnelID { + get { return tunnelID_; } + set { + tunnelID_ = value; + } + } + + /// Field number for the "Port" field. + public const int PortFieldNumber = 2; + private int port_; + /// + ///端口 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Port { + get { return port_; } + set { + port_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_Cfgs_Single); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_Cfgs_Single other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TunnelID != other.TunnelID) return false; + if (Port != other.Port) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (TunnelID != 0) hash ^= TunnelID.GetHashCode(); + if (Port != 0) hash ^= Port.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Port != 0) { + output.WriteRawTag(16); + output.WriteInt32(Port); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Port != 0) { + output.WriteRawTag(16); + output.WriteInt32(Port); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (TunnelID != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(TunnelID); + } + if (Port != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Port); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_Cfgs_Single other) { + if (other == null) { + return; + } + if (other.TunnelID != 0) { + TunnelID = other.TunnelID; + } + if (other.Port != 0) { + Port = other.Port; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Port = input.ReadInt32(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Port = input.ReadInt32(); + break; + } + } + } + } + #endif + + } + + /// + ///聊天 上行 + /// + public sealed partial class Protobuf_ChatMsg : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_ChatMsg()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufNoSugarReflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg(Protobuf_ChatMsg other) : this() { + chatMsg_ = other.chatMsg_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg Clone() { + return new Protobuf_ChatMsg(this); + } + + /// Field number for the "ChatMsg" field. + public const int ChatMsgFieldNumber = 1; + private string chatMsg_ = ""; + /// + ///消息 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ChatMsg { + get { return chatMsg_; } + set { + chatMsg_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_ChatMsg); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_ChatMsg other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ChatMsg != other.ChatMsg) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ChatMsg.Length != 0) hash ^= ChatMsg.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (ChatMsg.Length != 0) { + output.WriteRawTag(10); + output.WriteString(ChatMsg); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (ChatMsg.Length != 0) { + output.WriteRawTag(10); + output.WriteString(ChatMsg); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ChatMsg.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ChatMsg); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_ChatMsg other) { + if (other == null) { + return; + } + if (other.ChatMsg.Length != 0) { + ChatMsg = other.ChatMsg; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + ChatMsg = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + ChatMsg = input.ReadString(); + break; + } + } + } + } + #endif + + } + + /// + ///聊天 下行 + /// + public sealed partial class Protobuf_ChatMsg_RESP : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_ChatMsg_RESP()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufNoSugarReflection.Descriptor.MessageTypes[5]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg_RESP() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg_RESP(Protobuf_ChatMsg_RESP other) : this() { + nickName_ = other.nickName_; + chatMsg_ = other.chatMsg_; + date_ = other.date_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg_RESP Clone() { + return new Protobuf_ChatMsg_RESP(this); + } + + /// Field number for the "NickName" field. + public const int NickNameFieldNumber = 1; + private string nickName_ = ""; + /// + ///昵称 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string NickName { + get { return nickName_; } + set { + nickName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "ChatMsg" field. + public const int ChatMsgFieldNumber = 2; + private string chatMsg_ = ""; + /// + ///消息 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ChatMsg { + get { return chatMsg_; } + set { + chatMsg_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "Date" field. + public const int DateFieldNumber = 3; + private long date_; + /// + ///时间 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Date { + get { return date_; } + set { + date_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_ChatMsg_RESP); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_ChatMsg_RESP other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (NickName != other.NickName) return false; + if (ChatMsg != other.ChatMsg) return false; + if (Date != other.Date) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (NickName.Length != 0) hash ^= NickName.GetHashCode(); + if (ChatMsg.Length != 0) hash ^= ChatMsg.GetHashCode(); + if (Date != 0L) hash ^= Date.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (NickName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(NickName); + } + if (ChatMsg.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ChatMsg); + } + if (Date != 0L) { + output.WriteRawTag(24); + output.WriteInt64(Date); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (NickName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(NickName); + } + if (ChatMsg.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ChatMsg); + } + if (Date != 0L) { + output.WriteRawTag(24); + output.WriteInt64(Date); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (NickName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(NickName); + } + if (ChatMsg.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ChatMsg); + } + if (Date != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Date); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_ChatMsg_RESP other) { + if (other == null) { + return; + } + if (other.NickName.Length != 0) { + NickName = other.NickName; + } + if (other.ChatMsg.Length != 0) { + ChatMsg = other.ChatMsg; + } + if (other.Date != 0L) { + Date = other.Date; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + NickName = input.ReadString(); + break; + } + case 18: { + ChatMsg = input.ReadString(); + break; + } + case 24: { + Date = input.ReadInt64(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + NickName = input.ReadString(); + break; + } + case 18: { + ChatMsg = input.ReadString(); + break; + } + case 24: { + Date = input.ReadInt64(); + break; + } + } + } + } + #endif + + } + + public sealed partial class Protobuf_C2S_Connect : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_C2S_Connect()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufNoSugarReflection.Descriptor.MessageTypes[6]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_C2S_Connect() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_C2S_Connect(Protobuf_C2S_Connect other) : this() { + tunnelID_ = other.tunnelID_; + idx_ = other.idx_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_C2S_Connect Clone() { + return new Protobuf_C2S_Connect(this); + } + + /// Field number for the "TunnelID" field. + public const int TunnelIDFieldNumber = 1; + private uint tunnelID_; + /// + ///TunnelID + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint TunnelID { + get { return tunnelID_; } + set { + tunnelID_ = value; + } + } + + /// Field number for the "Idx" field. + public const int IdxFieldNumber = 2; + private uint idx_; + /// + ///单个隧道连接下标 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint Idx { + get { return idx_; } + set { + idx_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_C2S_Connect); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_C2S_Connect other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TunnelID != other.TunnelID) return false; + if (Idx != other.Idx) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (TunnelID != 0) hash ^= TunnelID.GetHashCode(); + if (Idx != 0) hash ^= Idx.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Idx != 0) { + output.WriteRawTag(16); + output.WriteUInt32(Idx); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Idx != 0) { + output.WriteRawTag(16); + output.WriteUInt32(Idx); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (TunnelID != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(TunnelID); + } + if (Idx != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Idx); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_C2S_Connect other) { + if (other == null) { + return; + } + if (other.TunnelID != 0) { + TunnelID = other.TunnelID; + } + if (other.Idx != 0) { + Idx = other.Idx; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Idx = input.ReadUInt32(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Idx = input.ReadUInt32(); + break; + } + } + } + } + #endif + + } + + public sealed partial class Protobuf_S2C_Connect : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_S2C_Connect()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufNoSugarReflection.Descriptor.MessageTypes[7]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_S2C_Connect() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_S2C_Connect(Protobuf_S2C_Connect other) : this() { + tunnelID_ = other.tunnelID_; + idx_ = other.idx_; + connected_ = other.connected_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_S2C_Connect Clone() { + return new Protobuf_S2C_Connect(this); + } + + /// Field number for the "TunnelID" field. + public const int TunnelIDFieldNumber = 1; + private uint tunnelID_; + /// + ///TunnelID + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint TunnelID { + get { return tunnelID_; } + set { + tunnelID_ = value; + } + } + + /// Field number for the "Idx" field. + public const int IdxFieldNumber = 2; + private uint idx_; + /// + ///单个隧道连接下标 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint Idx { + get { return idx_; } + set { + idx_ = value; + } + } + + /// Field number for the "Connected" field. + public const int ConnectedFieldNumber = 3; + private uint connected_; + /// + ///[0]连接失败 [1]连接成功 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint Connected { + get { return connected_; } + set { + connected_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_S2C_Connect); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_S2C_Connect other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TunnelID != other.TunnelID) return false; + if (Idx != other.Idx) return false; + if (Connected != other.Connected) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (TunnelID != 0) hash ^= TunnelID.GetHashCode(); + if (Idx != 0) hash ^= Idx.GetHashCode(); + if (Connected != 0) hash ^= Connected.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Idx != 0) { + output.WriteRawTag(16); + output.WriteUInt32(Idx); + } + if (Connected != 0) { + output.WriteRawTag(24); + output.WriteUInt32(Connected); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Idx != 0) { + output.WriteRawTag(16); + output.WriteUInt32(Idx); + } + if (Connected != 0) { + output.WriteRawTag(24); + output.WriteUInt32(Connected); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (TunnelID != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(TunnelID); + } + if (Idx != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Idx); + } + if (Connected != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Connected); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_S2C_Connect other) { + if (other == null) { + return; + } + if (other.TunnelID != 0) { + TunnelID = other.TunnelID; + } + if (other.Idx != 0) { + Idx = other.Idx; + } + if (other.Connected != 0) { + Connected = other.Connected; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Idx = input.ReadUInt32(); + break; + } + case 24: { + Connected = input.ReadUInt32(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Idx = input.ReadUInt32(); + break; + } + case 24: { + Connected = input.ReadUInt32(); + break; + } + } + } + } + #endif + + } + + public sealed partial class Protobuf_C2S_Disconnect : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_C2S_Disconnect()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufNoSugarReflection.Descriptor.MessageTypes[8]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_C2S_Disconnect() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_C2S_Disconnect(Protobuf_C2S_Disconnect other) : this() { + tunnelID_ = other.tunnelID_; + idx_ = other.idx_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_C2S_Disconnect Clone() { + return new Protobuf_C2S_Disconnect(this); + } + + /// Field number for the "TunnelID" field. + public const int TunnelIDFieldNumber = 1; + private uint tunnelID_; + /// + ///TunnelID + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint TunnelID { + get { return tunnelID_; } + set { + tunnelID_ = value; + } + } + + /// Field number for the "Idx" field. + public const int IdxFieldNumber = 2; + private uint idx_; + /// + ///单个隧道连接下标 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint Idx { + get { return idx_; } + set { + idx_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_C2S_Disconnect); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_C2S_Disconnect other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TunnelID != other.TunnelID) return false; + if (Idx != other.Idx) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (TunnelID != 0) hash ^= TunnelID.GetHashCode(); + if (Idx != 0) hash ^= Idx.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Idx != 0) { + output.WriteRawTag(16); + output.WriteUInt32(Idx); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Idx != 0) { + output.WriteRawTag(16); + output.WriteUInt32(Idx); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (TunnelID != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(TunnelID); + } + if (Idx != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Idx); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_C2S_Disconnect other) { + if (other == null) { + return; + } + if (other.TunnelID != 0) { + TunnelID = other.TunnelID; + } + if (other.Idx != 0) { + Idx = other.Idx; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Idx = input.ReadUInt32(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Idx = input.ReadUInt32(); + break; + } + } + } + } + #endif + + } + + public sealed partial class Protobuf_S2C_Disconnect : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_S2C_Disconnect()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufNoSugarReflection.Descriptor.MessageTypes[9]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_S2C_Disconnect() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_S2C_Disconnect(Protobuf_S2C_Disconnect other) : this() { + tunnelID_ = other.tunnelID_; + idx_ = other.idx_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_S2C_Disconnect Clone() { + return new Protobuf_S2C_Disconnect(this); + } + + /// Field number for the "TunnelID" field. + public const int TunnelIDFieldNumber = 1; + private uint tunnelID_; + /// + ///TunnelID + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint TunnelID { + get { return tunnelID_; } + set { + tunnelID_ = value; + } + } + + /// Field number for the "Idx" field. + public const int IdxFieldNumber = 2; + private uint idx_; + /// + ///单个隧道连接下标 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint Idx { + get { return idx_; } + set { + idx_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_S2C_Disconnect); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_S2C_Disconnect other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TunnelID != other.TunnelID) return false; + if (Idx != other.Idx) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (TunnelID != 0) hash ^= TunnelID.GetHashCode(); + if (Idx != 0) hash ^= Idx.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Idx != 0) { + output.WriteRawTag(16); + output.WriteUInt32(Idx); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Idx != 0) { + output.WriteRawTag(16); + output.WriteUInt32(Idx); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (TunnelID != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(TunnelID); + } + if (Idx != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Idx); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_S2C_Disconnect other) { + if (other == null) { + return; + } + if (other.TunnelID != 0) { + TunnelID = other.TunnelID; + } + if (other.Idx != 0) { + Idx = other.Idx; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Idx = input.ReadUInt32(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Idx = input.ReadUInt32(); + break; + } + } + } + } + #endif + + } + + public sealed partial class Protobuf_C2S_DATA : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_C2S_DATA()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufNoSugarReflection.Descriptor.MessageTypes[10]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_C2S_DATA() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_C2S_DATA(Protobuf_C2S_DATA other) : this() { + tunnelID_ = other.tunnelID_; + idx_ = other.idx_; + hunterNetCoreData_ = other.hunterNetCoreData_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_C2S_DATA Clone() { + return new Protobuf_C2S_DATA(this); + } + + /// Field number for the "TunnelID" field. + public const int TunnelIDFieldNumber = 1; + private uint tunnelID_; + /// + ///TunnelID + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint TunnelID { + get { return tunnelID_; } + set { + tunnelID_ = value; + } + } + + /// Field number for the "Idx" field. + public const int IdxFieldNumber = 2; + private uint idx_; + /// + ///单个隧道连接下标 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint Idx { + get { return idx_; } + set { + idx_ = value; + } + } + + /// Field number for the "HunterNetCore_Data" field. + public const int HunterNetCoreDataFieldNumber = 3; + private pb::ByteString hunterNetCoreData_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString HunterNetCoreData { + get { return hunterNetCoreData_; } + set { + hunterNetCoreData_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_C2S_DATA); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_C2S_DATA other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TunnelID != other.TunnelID) return false; + if (Idx != other.Idx) return false; + if (HunterNetCoreData != other.HunterNetCoreData) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (TunnelID != 0) hash ^= TunnelID.GetHashCode(); + if (Idx != 0) hash ^= Idx.GetHashCode(); + if (HunterNetCoreData.Length != 0) hash ^= HunterNetCoreData.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Idx != 0) { + output.WriteRawTag(16); + output.WriteUInt32(Idx); + } + if (HunterNetCoreData.Length != 0) { + output.WriteRawTag(26); + output.WriteBytes(HunterNetCoreData); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Idx != 0) { + output.WriteRawTag(16); + output.WriteUInt32(Idx); + } + if (HunterNetCoreData.Length != 0) { + output.WriteRawTag(26); + output.WriteBytes(HunterNetCoreData); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (TunnelID != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(TunnelID); + } + if (Idx != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Idx); + } + if (HunterNetCoreData.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(HunterNetCoreData); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_C2S_DATA other) { + if (other == null) { + return; + } + if (other.TunnelID != 0) { + TunnelID = other.TunnelID; + } + if (other.Idx != 0) { + Idx = other.Idx; + } + if (other.HunterNetCoreData.Length != 0) { + HunterNetCoreData = other.HunterNetCoreData; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Idx = input.ReadUInt32(); + break; + } + case 26: { + HunterNetCoreData = input.ReadBytes(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Idx = input.ReadUInt32(); + break; + } + case 26: { + HunterNetCoreData = input.ReadBytes(); + break; + } + } + } + } + #endif + + } + + public sealed partial class Protobuf_S2C_DATA : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_S2C_DATA()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufNoSugarReflection.Descriptor.MessageTypes[11]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_S2C_DATA() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_S2C_DATA(Protobuf_S2C_DATA other) : this() { + tunnelID_ = other.tunnelID_; + idx_ = other.idx_; + hunterNetCoreData_ = other.hunterNetCoreData_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_S2C_DATA Clone() { + return new Protobuf_S2C_DATA(this); + } + + /// Field number for the "TunnelID" field. + public const int TunnelIDFieldNumber = 1; + private uint tunnelID_; + /// + ///TunnelID + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint TunnelID { + get { return tunnelID_; } + set { + tunnelID_ = value; + } + } + + /// Field number for the "Idx" field. + public const int IdxFieldNumber = 2; + private uint idx_; + /// + ///单个隧道连接下标 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public uint Idx { + get { return idx_; } + set { + idx_ = value; + } + } + + /// Field number for the "HunterNetCore_Data" field. + public const int HunterNetCoreDataFieldNumber = 3; + private pb::ByteString hunterNetCoreData_ = pb::ByteString.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pb::ByteString HunterNetCoreData { + get { return hunterNetCoreData_; } + set { + hunterNetCoreData_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_S2C_DATA); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_S2C_DATA other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (TunnelID != other.TunnelID) return false; + if (Idx != other.Idx) return false; + if (HunterNetCoreData != other.HunterNetCoreData) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (TunnelID != 0) hash ^= TunnelID.GetHashCode(); + if (Idx != 0) hash ^= Idx.GetHashCode(); + if (HunterNetCoreData.Length != 0) hash ^= HunterNetCoreData.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Idx != 0) { + output.WriteRawTag(16); + output.WriteUInt32(Idx); + } + if (HunterNetCoreData.Length != 0) { + output.WriteRawTag(26); + output.WriteBytes(HunterNetCoreData); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (TunnelID != 0) { + output.WriteRawTag(8); + output.WriteUInt32(TunnelID); + } + if (Idx != 0) { + output.WriteRawTag(16); + output.WriteUInt32(Idx); + } + if (HunterNetCoreData.Length != 0) { + output.WriteRawTag(26); + output.WriteBytes(HunterNetCoreData); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (TunnelID != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(TunnelID); + } + if (Idx != 0) { + size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Idx); + } + if (HunterNetCoreData.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeBytesSize(HunterNetCoreData); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_S2C_DATA other) { + if (other == null) { + return; + } + if (other.TunnelID != 0) { + TunnelID = other.TunnelID; + } + if (other.Idx != 0) { + Idx = other.Idx; + } + if (other.HunterNetCoreData.Length != 0) { + HunterNetCoreData = other.HunterNetCoreData; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Idx = input.ReadUInt32(); + break; + } + case 26: { + HunterNetCoreData = input.ReadBytes(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 8: { + TunnelID = input.ReadUInt32(); + break; + } + case 16: { + Idx = input.ReadUInt32(); + break; + } + case 26: { + HunterNetCoreData = input.ReadBytes(); + break; + } + } + } + } + #endif + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/NoSugarNet.ClientCore/AppNoSugarNet.cs b/NoSugarNet.ClientCore/AppNoSugarNet.cs index faaaf2d..0ea2f24 100644 --- a/NoSugarNet.ClientCore/AppNoSugarNet.cs +++ b/NoSugarNet.ClientCore/AppNoSugarNet.cs @@ -26,7 +26,7 @@ namespace NoSugarNet.ClientCore public static event OnUpdateStatusHandler OnUpdateStatus; #endregion - public static void Init(string IP, int port, OnLogHandler onLog = null) + public static void Init(OnLogHandler onLog = null) { log = new LogManager(); if(onLog != null) @@ -37,14 +37,26 @@ namespace NoSugarNet.ClientCore local = new AppLocalClient(); user = new UserDataManager(); netStatus = new NetStatus(); + _SpeedCheckTimeTimer = new System.Timers.Timer(); + _SpeedCheckTimeTimer.Interval = TimerInterval; + _SpeedCheckTimeTimer.Elapsed += Checktimer_Elapsed; + _SpeedCheckTimeTimer.AutoReset = true; + } + + public static void Connect(string IP, int port) + { if (networkHelper.Init(IP, port)) - { - _SpeedCheckTimeTimer = new System.Timers.Timer(); - _SpeedCheckTimeTimer.Interval = TimerInterval; - _SpeedCheckTimeTimer.Elapsed += Checktimer_Elapsed; - _SpeedCheckTimeTimer.AutoReset = true; - _SpeedCheckTimeTimer.Enabled = true; - } + _SpeedCheckTimeTimer.Enabled = true; + else + _SpeedCheckTimeTimer.Enabled = false; + } + + public static void Close() + { + local.StopAll(); + networkHelper.CloseConntect(); + AppNoSugarNet.log.Info("停止"); + _SpeedCheckTimeTimer.Enabled = false; } static void Checktimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) @@ -66,7 +78,6 @@ namespace NoSugarNet.ClientCore tReciveSecSpeed = (local.tReciveAllLenght - netStatus.tReciveAllLenght) / (TimerInterval / 1000), }; netStatus = resutnetStatus; - OnUpdateStatus?.Invoke(resutnetStatus); } } diff --git a/NoSugarNet.ClientCore/Manager/AppLocalClient.cs b/NoSugarNet.ClientCore/Manager/AppLocalClient.cs index 919fb58..f7000c5 100644 --- a/NoSugarNet.ClientCore/Manager/AppLocalClient.cs +++ b/NoSugarNet.ClientCore/Manager/AppLocalClient.cs @@ -54,13 +54,13 @@ namespace ServerCore.Manager /// void InitListenerMode() { - AppNoSugarNet.log.Debug("初始化压缩适配器" + compressAdapterType); + AppNoSugarNet.log.Info("初始化压缩适配器" + compressAdapterType); //初始化压缩适配器,代表压缩类型 mCompressAdapter = new CompressAdapter(compressAdapterType); foreach (var cfg in mDictTunnelID2Cfg) { LocalListener listener = new LocalListener(256, 1024, cfg.Key); - AppNoSugarNet.log.Debug($"开始监听配置 Tunnel:{cfg.Key},Port:{cfg.Value.Port}"); + AppNoSugarNet.log.Info($"开始监听配置 Tunnel:{cfg.Key},Port:{cfg.Value.Port}"); listener.Init(); listener.Start(new IPEndPoint(IPAddress.Any.Address, (int)cfg.Value.Port)); //listener.Init((int)cfg.Value.Port); @@ -249,7 +249,7 @@ namespace ServerCore.Manager /// public void OnServerLocalDataCallBack(byte tunnelId,byte Idx, byte[] data) { - //AppNoSugarNet.log.Debug($"OnServerLocalDataCallBack {tunnelId},{Idx},Data长度:{data.Length}"); + //AppNoSugarNet.log.Info($"OnServerLocalDataCallBack {tunnelId},{Idx},Data长度:{data.Length}"); if (!GetLocalListener(tunnelId, out LocalListener _listener)) return; //记录压缩前数据长度 @@ -266,7 +266,7 @@ namespace ServerCore.Manager /// public void OnClientTunnelDataCallBack(byte tunnelId,byte Idx, byte[] data) { - //AppNoSugarNet.log.Debug($"OnClientTunnelDataCallBack {tunnelId},{Idx}"); + //AppNoSugarNet.log.Info($"OnClientTunnelDataCallBack {tunnelId},{Idx}"); int SlienLenght = 1000; //判断数据量大时分包 diff --git a/NoSugarNet.ClientCore/Manager/AppLogin.cs b/NoSugarNet.ClientCore/Manager/AppLogin.cs index 79431f3..73a013b 100644 --- a/NoSugarNet.ClientCore/Manager/AppLogin.cs +++ b/NoSugarNet.ClientCore/Manager/AppLogin.cs @@ -25,12 +25,12 @@ namespace NoSugarNet.ClientCore.Manager Protobuf_Login_RESP msg = ProtoBufHelper.DeSerizlize(reqData); if (msg.Status == LoginResultStatus.Ok) { - AppNoSugarNet.log.Debug("登录成功"); + AppNoSugarNet.log.Info("登录成功"); AppNoSugarNet.user.InitMainUserData(AppNoSugarNet.user.userdata.Account); } else { - AppNoSugarNet.log.Debug("登录失败"); + AppNoSugarNet.log.Info("登录失败"); } } diff --git a/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener.cs b/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener.cs index f4f4987..5501e4d 100644 --- a/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener.cs +++ b/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener.cs @@ -21,7 +21,7 @@ namespace NoSugarNet.ClientCore private void ClientNumberChange(int num, AsyncUserToken token) { - AppNoSugarNet.log.Debug("Client数发生变化"); + AppNoSugarNet.log.Info("Client数发生变化"); //增加连接数 if (num > 0) { @@ -61,7 +61,7 @@ namespace NoSugarNet.ClientCore public void DataCallBack(Socket sk, byte[] data) { - //AppNoSugarNet.log.Debug("收到消息 数据长度=>" + data.Length); + //AppNoSugarNet.log.Info("收到消息 数据长度=>" + data.Length); //记录接受长度 mReciveAllLenght += data.Length; if (!GetSocketIdxBySocket(sk, out int Idx)) @@ -73,7 +73,7 @@ namespace NoSugarNet.ClientCore } catch (Exception ex) { - AppNoSugarNet.log.Debug("逻辑处理错误:" + ex.ToString()); + AppNoSugarNet.log.Info("逻辑处理错误:" + ex.ToString()); } } @@ -91,7 +91,7 @@ namespace NoSugarNet.ClientCore /// public void OnDisconnect(AsyncUserToken token) { - AppNoSugarNet.log.Debug("断开连接"); + AppNoSugarNet.log.Info("断开连接"); if (!GetSocketIdxBySocket(token.Socket, out int Idx)) return; @@ -102,7 +102,7 @@ namespace NoSugarNet.ClientCore public void OnShowNetLog(string msg) { - AppNoSugarNet.log.Debug(msg); + AppNoSugarNet.log.Info(msg); } #region 一个轻量级无用户连接管理 @@ -205,9 +205,9 @@ namespace NoSugarNet.ClientCore if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo)) return; if (bConnected) - AppNoSugarNet.log.Debug("远端本地连接已连接!!!!"); + AppNoSugarNet.log.Info("远端本地连接已连接!!!!"); else - AppNoSugarNet.log.Debug("远端本地连接已断开连接!!!!"); + AppNoSugarNet.log.Info("远端本地连接已断开连接!!!!"); _localClientInfo.bRemoteConnect = bConnected; } diff --git a/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener_Source.cs b/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener_Source.cs index 40912ce..163b2c7 100644 --- a/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener_Source.cs +++ b/NoSugarNet.ClientCore/Manager/LocalClient/LocalListener_Source.cs @@ -22,7 +22,7 @@ namespace NoSugarNet.ClientCore private void ClientNumberChange(Socket socket) { - AppNoSugarNet.log.Debug("Client数发生变化"); + AppNoSugarNet.log.Info("Client数发生变化"); //增加连接数 int Idx = AddDictSocket(socket); if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInf)) @@ -59,7 +59,7 @@ namespace NoSugarNet.ClientCore public void DataCallBack(Socket sk, byte[] data) { - //AppNoSugarNet.log.Debug("收到消息 数据长度=>" + data.Length); + //AppNoSugarNet.log.Info("收到消息 数据长度=>" + data.Length); //记录接受长度 mReciveAllLenght += data.Length; if (!GetSocketIdxBySocket(sk, out int Idx)) @@ -83,7 +83,7 @@ namespace NoSugarNet.ClientCore } catch (Exception ex) { - AppNoSugarNet.log.Debug("逻辑处理错误:" + ex.ToString()); + AppNoSugarNet.log.Info("逻辑处理错误:" + ex.ToString()); } } @@ -101,7 +101,7 @@ namespace NoSugarNet.ClientCore /// public void OnDisconnectClient(Socket sk) { - AppNoSugarNet.log.Debug("断开连接"); + AppNoSugarNet.log.Info("断开连接"); if (!GetSocketIdxBySocket(sk, out int Idx)) return; @@ -112,7 +112,7 @@ namespace NoSugarNet.ClientCore public void OnShowNetLog(string msg) { - AppNoSugarNet.log.Debug(msg); + AppNoSugarNet.log.Info(msg); } #region 一个轻量级无用户连接管理 @@ -233,9 +233,9 @@ namespace NoSugarNet.ClientCore if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo)) return; if (bConnected) - AppNoSugarNet.log.Debug("远端本地连接已连接!!!!"); + AppNoSugarNet.log.Info("远端本地连接已连接!!!!"); else - AppNoSugarNet.log.Debug("远端本地连接已断开连接!!!!"); + AppNoSugarNet.log.Info("远端本地连接已断开连接!!!!"); _localClientInfo.bRemoteConnect = bConnected; } diff --git a/NoSugarNet.ClientCore/Manager/LocalClient/LocalMsgQueuePool.cs b/NoSugarNet.ClientCore/Manager/LocalClient/LocalMsgQueuePool.cs index 1a80ff0..4f832b0 100644 --- a/NoSugarNet.ClientCore/Manager/LocalClient/LocalMsgQueuePool.cs +++ b/NoSugarNet.ClientCore/Manager/LocalClient/LocalMsgQueuePool.cs @@ -1,4 +1,4 @@ -namespace HaoYueNet.ServerNetwork +namespace NoSugarNet.ClientCore { public class IdxWithMsg { diff --git a/NoSugarNet.ClientCore/Manager/LogManager.cs b/NoSugarNet.ClientCore/Manager/LogManager.cs index f07fd60..8b2a504 100644 --- a/NoSugarNet.ClientCore/Manager/LogManager.cs +++ b/NoSugarNet.ClientCore/Manager/LogManager.cs @@ -2,6 +2,13 @@ { public class LogManager { + public enum E_LogType:byte + { + Info = 0, + Debug = 1, + Warning = 2, + Error = 3, + } /// /// 日志 /// @@ -13,19 +20,29 @@ /// public static event OnLogHandler OnLog; + public void Info(string str) + { + Log(E_LogType.Info, str); + } + public void Debug(string str) { - OnLog?.Invoke(0,str); + Log(E_LogType.Debug, str); } public void Warning(string str) { - OnLog?.Invoke(1,str); + Log(E_LogType.Warning, str); } public void Error(string str) { - OnLog?.Invoke(2,str); + Log(E_LogType.Error, str); + } + + public void Log(E_LogType logtype,string str) + { + OnLog?.Invoke((int)logtype, str); } } } \ No newline at end of file diff --git a/NoSugarNet.ClientCore/Network/NetworkHelper.cs b/NoSugarNet.ClientCore/Network/NetworkHelper.cs index 5950979..430c587 100644 --- a/NoSugarNet.ClientCore/Network/NetworkHelper.cs +++ b/NoSugarNet.ClientCore/Network/NetworkHelper.cs @@ -60,7 +60,7 @@ namespace NoSugarNet.ClientCore.Network { //用于Unity内的输出 //Debug.Log("NetCoreDebug >> "+str); - AppNoSugarNet.log.Debug("NetCoreDebug >> " + str); + AppNoSugarNet.log.Info("NetCoreDebug >> " + str); } /// @@ -114,13 +114,13 @@ namespace NoSugarNet.ClientCore.Network { //等待时间 Thread.Sleep(ReConnectTryTime); - AppNoSugarNet.log.Debug($"尝试自动重连{LastConnectIP}:{LastConnectPort}……"); + AppNoSugarNet.log.Info($"尝试自动重连{LastConnectIP}:{LastConnectPort}……"); //第一步 if (Init(LastConnectIP, LastConnectPort)) { - AppNoSugarNet.log.Debug($"自动重连成功!"); + AppNoSugarNet.log.Info($"自动重连成功!"); bflagDone = true; - AppNoSugarNet.log.Debug($"触发重连后的自动逻辑!"); + AppNoSugarNet.log.Info($"触发重连后的自动逻辑!"); OnReConnected?.Invoke(); } } while (!bflagDone); diff --git a/NoSugarNet.ClientCore/NoSugarNet.ClientCore.csproj b/NoSugarNet.ClientCore/NoSugarNet.ClientCore.csproj index 2304238..b70b7b3 100644 --- a/NoSugarNet.ClientCore/NoSugarNet.ClientCore.csproj +++ b/NoSugarNet.ClientCore/NoSugarNet.ClientCore.csproj @@ -4,11 +4,7 @@ net8.0 enable enable - - - - - + @@ -20,6 +16,9 @@ ..\Lib\HaoYueNet.ServerNetwork.dll + + ..\Lib\NoSugarNet.DataHelper.dll + diff --git a/NoSugarNet.DataHelper/Common/CompressAdapter.cs b/NoSugarNet.DataHelper/Common/CompressAdapter.cs index e22ab8f..80bbd0f 100644 --- a/NoSugarNet.DataHelper/Common/CompressAdapter.cs +++ b/NoSugarNet.DataHelper/Common/CompressAdapter.cs @@ -1,4 +1,5 @@ -using System.IO.Compression; +using System.IO; +using System.IO.Compression; namespace NoSugarNet.DataHelper { @@ -49,8 +50,8 @@ namespace NoSugarNet.DataHelper public interface IDataCompress { - public byte[] Compress(byte[] data); - public byte[] Decompress(byte[] data); + byte[] Compress(byte[] data); + byte[] Decompress(byte[] data); } public class NoCompress : IDataCompress diff --git a/NoSugarNet.DataHelper/NoSugarNet.DataHelper.csproj b/NoSugarNet.DataHelper/NoSugarNet.DataHelper.csproj index fa71b7a..ad3ae5d 100644 --- a/NoSugarNet.DataHelper/NoSugarNet.DataHelper.csproj +++ b/NoSugarNet.DataHelper/NoSugarNet.DataHelper.csproj @@ -1,9 +1,9 @@  - - net8.0 - enable - enable + netstandard2.0 - - + + + 8.0 + + \ No newline at end of file diff --git a/NoSugarNet.DataHelper/NoSugarNet.DataHelper.csproj.user b/NoSugarNet.DataHelper/NoSugarNet.DataHelper.csproj.user new file mode 100644 index 0000000..403e972 --- /dev/null +++ b/NoSugarNet.DataHelper/NoSugarNet.DataHelper.csproj.user @@ -0,0 +1,6 @@ + + + + <_LastSelectedProfileId>F:\Sin365\NoSugarNet\NoSugarNet.DataHelper\Properties\PublishProfiles\FolderProfile.pubxml + + \ No newline at end of file diff --git a/NoSugarNet.sln b/NoSugarNet.sln index a77fd95..fccbf7b 100644 --- a/NoSugarNet.sln +++ b/NoSugarNet.sln @@ -22,16 +22,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoSugarNet.ServerCli", "Sam EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoSugarNet.DataHelper", "NoSugarNet.DataHelper\NoSugarNet.DataHelper.csproj", "{3C41B685-B46B-4057-826B-C8C6F395BFA8}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Net4X", "Net4X", "{4A660CAE-CD92-411C-9D8E-7CB677DB3C74}" - ProjectSection(SolutionItems) = preProject - Lib\Net4x\HaoYueNet.ClientNetworkNet4x.dll = Lib\Net4x\HaoYueNet.ClientNetworkNet4x.dll - Lib\Net4x\HaoYueNet.ServerNetworkNet4x.dll = Lib\Net4x\HaoYueNet.ServerNetworkNet4x.dll - Lib\Net4x\System.Buffers.dll = Lib\Net4x\System.Buffers.dll - Lib\Net4x\System.Memory.dll = Lib\Net4x\System.Memory.dll - Lib\Net4x\System.Runtime.CompilerServices.Unsafe.dll = Lib\Net4x\System.Runtime.CompilerServices.Unsafe.dll - EndProjectSection +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NetLib_Standard2", "NetLib_Standard2", "{4A660CAE-CD92-411C-9D8E-7CB677DB3C74}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoSugarNet.ClientCoreNet4x", "NoSugarNet.ClientCoreNet4x\NoSugarNet.ClientCoreNet4x.csproj", "{F565C3B8-E210-45F5-9B9E-8C1A49438753}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoSugarNet.ClientCore.Standard2", "NoSugarNet.ClientCore.Standard2\NoSugarNet.ClientCore.Standard2.csproj", "{5DB2B608-6F99-430A-99AC-534410393955}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -59,10 +52,10 @@ Global {3C41B685-B46B-4057-826B-C8C6F395BFA8}.Debug|Any CPU.Build.0 = Debug|Any CPU {3C41B685-B46B-4057-826B-C8C6F395BFA8}.Release|Any CPU.ActiveCfg = Release|Any CPU {3C41B685-B46B-4057-826B-C8C6F395BFA8}.Release|Any CPU.Build.0 = Release|Any CPU - {F565C3B8-E210-45F5-9B9E-8C1A49438753}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F565C3B8-E210-45F5-9B9E-8C1A49438753}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F565C3B8-E210-45F5-9B9E-8C1A49438753}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F565C3B8-E210-45F5-9B9E-8C1A49438753}.Release|Any CPU.Build.0 = Release|Any CPU + {5DB2B608-6F99-430A-99AC-534410393955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5DB2B608-6F99-430A-99AC-534410393955}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5DB2B608-6F99-430A-99AC-534410393955}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5DB2B608-6F99-430A-99AC-534410393955}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/NosugarNetForUnity/Assets/MainUI.cs b/NosugarNetForUnity/Assets/MainUI.cs index f433763..d539806 100644 --- a/NosugarNetForUnity/Assets/MainUI.cs +++ b/NosugarNetForUnity/Assets/MainUI.cs @@ -1,4 +1,4 @@ -using NoSugarNet.ClientCoreNet4x; +using NoSugarNet.ClientCoreNet.Standard2; using System; using System.Collections; using System.Collections.Generic; @@ -9,16 +9,32 @@ public class MainUI : MonoBehaviour { public Button btnStart; + public Button btnStop; public InputField inputIP; public InputField inputPort; - public Text textLog; // Start is called before the first frame update void Start() { + + string LastIP = PlayerPrefs.GetString("LastIP"); + string LastPort = PlayerPrefs.GetString("LastPort"); + if(!string.IsNullOrEmpty(LastIP)) + inputIP.text = LastIP; + if (!string.IsNullOrEmpty(LastPort)) + inputPort.text = LastPort; + btnStart.onClick.AddListener(InitNoSugarNetClient); - textLog.text = "-"; - AddLog("123"); + btnStop.onClick.AddListener(StopNoSugarNetClient); + AddLog(""); + + AppNoSugarNet.OnUpdateStatus += OnUpdateStatus; + AppNoSugarNet.Init(OnNoSugarNetLog); + } + + private void OnDisable() + { + AppNoSugarNet.Close(); } // Update is called once per frame @@ -34,8 +50,14 @@ public class MainUI : MonoBehaviour OnNoSugarNetLog(0,"ô"); return; } - AppNoSugarNet.OnUpdateStatus += OnUpdateStatus; - AppNoSugarNet.Init(inputIP.text, Convert.ToInt32(inputPort.text), OnNoSugarNetLog); + + PlayerPrefs.SetString("LastIP", inputIP.text); + PlayerPrefs.GetString("LastPort",inputPort.text); + AppNoSugarNet.Connect(inputIP.text, Convert.ToInt32(inputPort.text)); + } + void StopNoSugarNetClient() + { + AppNoSugarNet.Close(); } @@ -63,7 +85,10 @@ public class MainUI : MonoBehaviour // С style.fontSize = 24; - GUI.TextField(new Rect(10, 300, Screen.width - 20, 1000), logText, style); + style.fontStyle = FontStyle.Bold; + style.normal.textColor = Color.white; + + GUI.TextField(new Rect(10, 400, Screen.width - 20, 1520), logText, style); } static void AddLog(string msg) @@ -72,7 +97,7 @@ public class MainUI : MonoBehaviour logText += string.Format("{0}\n", System.DateTime.Now.ToString("HH:mm:ss> ") + msg); // ıʾ - if (logText.Split('\n').Length > 50) + if (logText.Split('\n').Length > 80) { string[] lines = logText.Split('\n'); logText = ""; diff --git a/NosugarNetForUnity/Assets/MainUI.prefab b/NosugarNetForUnity/Assets/MainUI.prefab index 43be55c..8c78ea9 100644 --- a/NosugarNetForUnity/Assets/MainUI.prefab +++ b/NosugarNetForUnity/Assets/MainUI.prefab @@ -33,12 +33,12 @@ RectTransform: - {fileID: 4996346368674553336} - {fileID: 4996346368210045502} m_Father: {fileID: 4996346368486089535} - m_RootOrder: 2 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -262.22324, y: 820.0001} - m_SizeDelta: {x: 524.4465, y: 156.28} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 282.9455, y: -113.47998} + m_SizeDelta: {x: 534.784, y: 103.25} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &4996346366834629249 CanvasRenderer: @@ -138,7 +138,7 @@ MonoBehaviour: m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} m_CustomCaretColor: 0 m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} - m_Text: 127.0.0.1 + m_Text: 139.186.160.243 m_CaretBlinkRate: 0.85 m_CaretWidth: 1 m_ReadOnly: 0 @@ -254,12 +254,12 @@ RectTransform: m_Children: - {fileID: 4996346367104132246} m_Father: {fileID: 4996346368486089535} - m_RootOrder: 1 + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 409.68347, y: 820} - m_SizeDelta: {x: 238.7751, y: 156.2808} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 816.7334, y: -113.47998} + m_SizeDelta: {x: 174.8618, y: 103.2501} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &4996346367916384534 CanvasRenderer: @@ -376,12 +376,12 @@ RectTransform: - {fileID: 4996346368504347606} - {fileID: 4996346368893432072} m_Father: {fileID: 4996346368486089535} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 146.883, y: 820.0001} - m_SizeDelta: {x: 261.3027, y: 156.28} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 639.8202, y: -113.47998} + m_SizeDelta: {x: 178.9625, y: 103.25} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &4996346368177541231 CanvasRenderer: @@ -481,7 +481,7 @@ MonoBehaviour: m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} m_CustomCaretColor: 0 m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} - m_Text: 10001 + m_Text: 1000 m_CaretBlinkRate: 0.85 m_CaretWidth: 1 m_ReadOnly: 0 @@ -564,103 +564,7 @@ MonoBehaviour: m_HorizontalOverflow: 1 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: 127.0.0.1 ---- !u!1 &4996346368454841980 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 4996346368454841971} - - component: {fileID: 4996346368454841969} - - component: {fileID: 4996346368454841970} - m_Layer: 5 - m_Name: log - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &4996346368454841971 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4996346368454841980} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4996346368486089535} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -136.23236} - m_SizeDelta: {x: 0, y: -272.4646} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &4996346368454841969 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4996346368454841980} - m_CullTransparentMesh: 1 ---- !u!114 &4996346368454841970 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4996346368454841980} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 64 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 168 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: 'New Text - - New Text - - New Text - - New Text - - New TextNew Text - - New - Text - - New Text - - New Text - - New Text' + m_Text: 139.186.160.243 --- !u!1 &4996346368486089528 GameObject: m_ObjectHideFlags: 0 @@ -691,10 +595,10 @@ RectTransform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 4996346368454841971} - {fileID: 4996346367916384529} - {fileID: 4996346366834629260} - {fileID: 4996346368177541226} + - {fileID: 7539436960902585095} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -724,7 +628,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0, g: 0, b: 0, a: 0.6745098} + m_Color: {r: 0, g: 0, b: 0, a: 1} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 @@ -754,9 +658,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: btnStart: {fileID: 4996346367916384528} + btnStop: {fileID: 8117411947949469824} inputIP: {fileID: 4996346366834629251} inputPort: {fileID: 4996346368177541225} - textLog: {fileID: 4996346368454841970} --- !u!1 &4996346368504347607 GameObject: m_ObjectHideFlags: 0 @@ -993,4 +897,204 @@ MonoBehaviour: m_HorizontalOverflow: 1 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: 10001 + m_Text: 1000 +--- !u!1 &6186141588528339253 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7539436960902585095} + - component: {fileID: 8969929348320387260} + - component: {fileID: 5841535602750926888} + - component: {fileID: 8117411947949469824} + m_Layer: 5 + m_Name: btnStop + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7539436960902585095 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6186141588528339253} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 5278454553715044843} + m_Father: {fileID: 4996346368486089535} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 993.73157, y: -113.47998} + m_SizeDelta: {x: 172.537, y: 103.2501} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &8969929348320387260 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6186141588528339253} + m_CullTransparentMesh: 1 +--- !u!114 &5841535602750926888 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6186141588528339253} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!114 &8117411947949469824 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6186141588528339253} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 5841535602750926888} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!1 &9128063835190157119 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5278454553715044843} + - component: {fileID: 2931565232197910918} + - component: {fileID: 2465264613758728606} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &5278454553715044843 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9128063835190157119} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7539436960902585095} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2931565232197910918 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9128063835190157119} + m_CullTransparentMesh: 1 +--- !u!114 &2465264613758728606 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9128063835190157119} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 84 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 92 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u505C\u6B62" diff --git a/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ClientNetworkNet.Standard2.dll b/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ClientNetworkNet.Standard2.dll new file mode 100644 index 0000000..c3c4a90 Binary files /dev/null and b/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ClientNetworkNet.Standard2.dll differ diff --git a/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ClientNetworkNet4x.dll.meta b/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ClientNetworkNet.Standard2.dll.meta similarity index 93% rename from NosugarNetForUnity/Assets/Plugins/HaoYueNet.ClientNetworkNet4x.dll.meta rename to NosugarNetForUnity/Assets/Plugins/HaoYueNet.ClientNetworkNet.Standard2.dll.meta index 8574193..fa5284c 100644 --- a/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ClientNetworkNet4x.dll.meta +++ b/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ClientNetworkNet.Standard2.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 368515f1ed1e54a42b6a8dfb547ca20c +guid: 324deac494a24a7499801349c7908062 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ClientNetworkNet4x.dll b/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ClientNetworkNet4x.dll deleted file mode 100644 index b71c2fd..0000000 Binary files a/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ClientNetworkNet4x.dll and /dev/null differ diff --git a/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ServerNetwork.Standard2.dll b/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ServerNetwork.Standard2.dll new file mode 100644 index 0000000..f525fd2 Binary files /dev/null and b/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ServerNetwork.Standard2.dll differ diff --git a/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ServerNetworkNet4x.dll.meta b/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ServerNetwork.Standard2.dll.meta similarity index 93% rename from NosugarNetForUnity/Assets/Plugins/HaoYueNet.ServerNetworkNet4x.dll.meta rename to NosugarNetForUnity/Assets/Plugins/HaoYueNet.ServerNetwork.Standard2.dll.meta index 368bc10..07f0863 100644 --- a/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ServerNetworkNet4x.dll.meta +++ b/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ServerNetwork.Standard2.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 1f9384be4094cf448a9f7458308f9af9 +guid: bba3137572a9a52478aa945ce387a192 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ServerNetworkNet4x.dll b/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ServerNetworkNet4x.dll deleted file mode 100644 index f57bef1..0000000 Binary files a/NosugarNetForUnity/Assets/Plugins/HaoYueNet.ServerNetworkNet4x.dll and /dev/null differ diff --git a/NosugarNetForUnity/Assets/Plugins/NoSugarNet.ClientCore.Standard2.dll b/NosugarNetForUnity/Assets/Plugins/NoSugarNet.ClientCore.Standard2.dll new file mode 100644 index 0000000..58d737f Binary files /dev/null and b/NosugarNetForUnity/Assets/Plugins/NoSugarNet.ClientCore.Standard2.dll differ diff --git a/NosugarNetForUnity/Assets/Plugins/NoSugarNet.ClientCoreNet4x.dll.meta b/NosugarNetForUnity/Assets/Plugins/NoSugarNet.ClientCore.Standard2.dll.meta similarity index 93% rename from NosugarNetForUnity/Assets/Plugins/NoSugarNet.ClientCoreNet4x.dll.meta rename to NosugarNetForUnity/Assets/Plugins/NoSugarNet.ClientCore.Standard2.dll.meta index 4b0bec0..dbe316c 100644 --- a/NosugarNetForUnity/Assets/Plugins/NoSugarNet.ClientCoreNet4x.dll.meta +++ b/NosugarNetForUnity/Assets/Plugins/NoSugarNet.ClientCore.Standard2.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3d415ce2c5ebcd641b5c9b76fc5a7da8 +guid: 208c5b5b9ca9139418ec61b89a1516ed PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/NosugarNetForUnity/Assets/Plugins/NoSugarNet.ClientCoreNet4x.dll b/NosugarNetForUnity/Assets/Plugins/NoSugarNet.ClientCoreNet4x.dll deleted file mode 100644 index d8597c0..0000000 Binary files a/NosugarNetForUnity/Assets/Plugins/NoSugarNet.ClientCoreNet4x.dll and /dev/null differ diff --git a/NosugarNetForUnity/Assets/Plugins/NoSugarNet.DataHelper.dll b/NosugarNetForUnity/Assets/Plugins/NoSugarNet.DataHelper.dll new file mode 100644 index 0000000..46e3832 Binary files /dev/null and b/NosugarNetForUnity/Assets/Plugins/NoSugarNet.DataHelper.dll differ diff --git a/NosugarNetForUnity/Assets/Plugins/NoSugarNet.DataHelper.dll.meta b/NosugarNetForUnity/Assets/Plugins/NoSugarNet.DataHelper.dll.meta new file mode 100644 index 0000000..2b3ed26 --- /dev/null +++ b/NosugarNetForUnity/Assets/Plugins/NoSugarNet.DataHelper.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 1d83e3c67ee8b794c97b5876ece7a16e +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/NosugarNetForUnity/Assets/Plugins/System.Buffers.dll b/NosugarNetForUnity/Assets/Plugins/System.Buffers.dll index 14e5c53..c0970c0 100644 Binary files a/NosugarNetForUnity/Assets/Plugins/System.Buffers.dll and b/NosugarNetForUnity/Assets/Plugins/System.Buffers.dll differ diff --git a/NosugarNetForUnity/Assets/Plugins/System.Memory.dll b/NosugarNetForUnity/Assets/Plugins/System.Memory.dll index 31486d6..1e6aef8 100644 Binary files a/NosugarNetForUnity/Assets/Plugins/System.Memory.dll and b/NosugarNetForUnity/Assets/Plugins/System.Memory.dll differ diff --git a/NosugarNetForUnity/Assets/Plugins/System.Numerics.Vectors.dll b/NosugarNetForUnity/Assets/Plugins/System.Numerics.Vectors.dll new file mode 100644 index 0000000..a808165 Binary files /dev/null and b/NosugarNetForUnity/Assets/Plugins/System.Numerics.Vectors.dll differ diff --git a/NosugarNetForUnity/Assets/Plugins/System.Numerics.Vectors.dll.meta b/NosugarNetForUnity/Assets/Plugins/System.Numerics.Vectors.dll.meta new file mode 100644 index 0000000..6e2fab3 --- /dev/null +++ b/NosugarNetForUnity/Assets/Plugins/System.Numerics.Vectors.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 677f64bf577a1724699f45841c5bcb04 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/NosugarNetForUnity/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll b/NosugarNetForUnity/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll index b50dbc4..b17135b 100644 Binary files a/NosugarNetForUnity/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll and b/NosugarNetForUnity/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll differ diff --git a/NosugarNetForUnity/Assets/Scenes/SampleScene.unity b/NosugarNetForUnity/Assets/Scenes/SampleScene.unity index f964fa6..92fba60 100644 --- a/NosugarNetForUnity/Assets/Scenes/SampleScene.unity +++ b/NosugarNetForUnity/Assets/Scenes/SampleScene.unity @@ -477,6 +477,22 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 1414424416} m_Modifications: + - target: {fileID: 4996346366834629251, guid: 1706084c5d625e2459ee1aaebb264e40, type: 3} + propertyPath: m_Text + value: 127.0.0.1 + objectReference: {fileID: 0} + - target: {fileID: 4996346368454841970, guid: 1706084c5d625e2459ee1aaebb264e40, type: 3} + propertyPath: m_Color.b + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4996346368454841970, guid: 1706084c5d625e2459ee1aaebb264e40, type: 3} + propertyPath: m_Color.g + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4996346368454841970, guid: 1706084c5d625e2459ee1aaebb264e40, type: 3} + propertyPath: m_Color.r + value: 0 + objectReference: {fileID: 0} - target: {fileID: 4996346368486089528, guid: 1706084c5d625e2459ee1aaebb264e40, type: 3} propertyPath: m_Name value: MainUI diff --git a/Sample/NoSugarNet.ClientCli/Program.cs b/Sample/NoSugarNet.ClientCli/Program.cs index 67a5ff9..1f72b17 100644 --- a/Sample/NoSugarNet.ClientCli/Program.cs +++ b/Sample/NoSugarNet.ClientCli/Program.cs @@ -14,10 +14,25 @@ namespace NoSugarNet.ClientCli return; } AppNoSugarNet.OnUpdateStatus += OnUpdateStatus; - AppNoSugarNet.Init(Config.ServerIP, Config.ServerPort, OnNoSugarNetLog); + AppNoSugarNet.Init(OnNoSugarNetLog); + AppNoSugarNet.Connect(Config.ServerIP, Config.ServerPort); while (true) { - Console.ReadLine(); + string CommandStr = Console.ReadLine(); + string Command = ""; + Command = ((CommandStr.IndexOf(" ") <= 0) ? CommandStr : CommandStr.Substring(0, CommandStr.IndexOf(" "))); + string[] CmdArr = CommandStr.Split(' '); + switch (Command) + { + case "con": + AppNoSugarNet.Connect(Config.ServerIP, Config.ServerPort); + break; + case "stop": + AppNoSugarNet.Close(); + break; + default: + break; + } } } static void OnUpdateStatus(NetStatus netState)