修复客户端重连问题

This commit is contained in:
sin365 2024-06-21 17:17:32 +08:00
parent ed48aade15
commit 59ee584c2c
16 changed files with 356 additions and 275 deletions

Binary file not shown.

Binary file not shown.

View File

@ -49,6 +49,24 @@ namespace ServerCore.Manager
ClientUserCount = mDictTunnelID2Listeners.Count;
}
public void GetClientDebugInfo()
{
AppNoSugarNet.log.Debug($"------------ mDictTunnelID2Listeners {mDictTunnelID2Listeners.Count} ------------");
lock (mDictTunnelID2Listeners)
{
foreach (var item in mDictTunnelID2Listeners)
{
var cinfo = item.Value.GetDictIdx2LocalClientInfo();
AppNoSugarNet.log.Debug($"----- TunnelID {item.Key} ObjcurrSeed->{item.Value.currSeed} ClientList->{item.Value.ClientList.Count} Idx2LocalClient->{cinfo.Count} -----");
foreach (var c in cinfo)
{
AppNoSugarNet.log.Debug($"----- Idx {c.Key} bRemoteConnect->{c.Value.bRemoteConnect} msgQueue.Count->{c.Value.msgQueue.Count} -----");
}
}
}
}
/// <summary>
/// 初始化连接,先获取到配置
/// </summary>
@ -114,10 +132,12 @@ namespace ServerCore.Manager
for (int i = 0; i < keys.Length; i++)
{
LocalListener _listener = mDictTunnelID2Listeners[keys[i]];
_listener.StopAll();
_listener.StopAllLocalClient();
_listener.Stop();
//_listener.Stop();
RemoveLocalListener(_listener);
}
mDictTunnelID2Listeners.Clear();
}
}
#endregion
@ -266,7 +286,7 @@ namespace ServerCore.Manager
/// <param name="data"></param>
public void OnClientTunnelDataCallBack(byte tunnelId,byte Idx, byte[] data)
{
//AppNoSugarNet.log.Info($"OnClientTunnelDataCallBack {tunnelId},{Idx}");
//AppNoSugarNet.log.Info($"OnClientTunnelDataCallBack {tunnelId},{Idx} data.Length->{data.Length}");
int SlienLenght = 1000;
//判断数据量大时分包

View File

@ -6,16 +6,22 @@ namespace NoSugarNet.ClientCore.Manager
{
public class AppLogin
{
static string LastLoginGuid = "";
public AppLogin()
{
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdLogin, RecvLoginMsg);
}
public void Login(string Account)
public void Login()
{
if(string.IsNullOrEmpty(LastLoginGuid))
LastLoginGuid = Guid.NewGuid().ToString();
AppNoSugarNet.user.userdata.Account = LastLoginGuid;
Protobuf_Login msg = new Protobuf_Login()
{
LoginType = 0,
Account = Account,
Account = AppNoSugarNet.user.userdata.Account,
};
AppNoSugarNet.networkHelper.SendToServer((int)CommandID.CmdLogin, ProtoBufHelper.Serizlize(msg));
}

View File

@ -8,6 +8,9 @@ namespace NoSugarNet.ClientCore
public byte mTunnelID;
public long mReciveAllLenght;
public long mSendAllLenght;
public long currSeed;
static long Seed;
public LocalListener(int numConnections, int receiveBufferSize, byte TunnelID)
: base(numConnections, receiveBufferSize)
{
@ -17,12 +20,14 @@ namespace NoSugarNet.ClientCore
OnNetLog += OnShowNetLog;
mTunnelID = TunnelID;
currSeed = Seed++;
}
private void ClientNumberChange(int num, AsyncUserToken token)
{
AppNoSugarNet.log.Info("Client数发生变化");
//增加连接数
//增加连接数stsc
if (num > 0)
{
int Idx = AddDictSocket(token.Socket);
@ -79,9 +84,16 @@ namespace NoSugarNet.ClientCore
public void CloseConnectByIdx(byte Idx)
{
if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInf))
if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo))
{
_localClientInf._socket.Shutdown(SocketShutdown.Both);
//把未发送消息队列回收了
while (_localClientInfo.msgQueue.Count > 0)
{
IdxWithMsg msg = _localClientInfo.msgQueue.Dequeue();
AppNoSugarNet.local._localMsgPool.Enqueue(msg);
}
_localClientInfo._socket.Shutdown(SocketShutdown.Both);
}
}
@ -118,6 +130,11 @@ namespace NoSugarNet.ClientCore
public Queue<IdxWithMsg> msgQueue = new Queue<IdxWithMsg>();
}
public Dictionary<int, LocalClientInfo> GetDictIdx2LocalClientInfo()
{
return DictIdx2LocalClientInfo;
}
int GetNextIdx()
{
if (FreeIdxs.Count > 0)
@ -129,6 +146,12 @@ namespace NoSugarNet.ClientCore
return mSeedIdx++;
}
void ResetFree()
{
FreeIdxs.Clear();
mSeedIdx = 0;
}
/// <summary>
/// 追加Socket返回下标
/// </summary>
@ -143,6 +166,7 @@ namespace NoSugarNet.ClientCore
int Idx = GetNextIdx();
DictSocketHandle2Idx[socket.Handle] = Idx;
DictIdx2LocalClientInfo[Idx] = new LocalClientInfo() { _socket = socket,bRemoteConnect = false};
AppNoSugarNet.log.Debug($"AddDictSocket mTunnelID->{mTunnelID} Idx->{Idx} socket.Handle{socket.Handle}");
return Idx;
}
}
@ -160,6 +184,7 @@ namespace NoSugarNet.ClientCore
if (DictIdx2LocalClientInfo.ContainsKey(Idx))
DictIdx2LocalClientInfo.Remove(Idx);
DictSocketHandle2Idx.Remove(socket.Handle);
AppNoSugarNet.log.Debug($"RemoveDictSocket mTunnelID->{mTunnelID} Idx->{Idx} socket.Handle{socket.Handle}");
}
}
@ -211,7 +236,7 @@ namespace NoSugarNet.ClientCore
_localClientInfo.bRemoteConnect = bConnected;
}
public void StopAll()
public void StopAllLocalClient()
{
lock (DictIdx2LocalClientInfo)
{
@ -221,6 +246,14 @@ namespace NoSugarNet.ClientCore
CloseConnectByIdx((byte)Idxs[i]);
}
DictIdx2LocalClientInfo.Clear();
DictSocketHandle2Idx.Clear();
ResetFree();
//清理事件
OnClientNumberChange -= ClientNumberChange;
OnReceive -= ReceiveData;
OnDisconnected -= OnDisconnect;
OnNetLog -= OnShowNetLog;
}
}

View File

@ -1,290 +1,296 @@
using HaoYueNet.ClientNetwork.OtherMode;
using HaoYueNet.ServerNetwork;
using System.Net.Sockets;
//using HaoYueNet.ClientNetwork.OtherMode;
//using HaoYueNet.ServerNetwork;
//using System.Net.Sockets;
namespace NoSugarNet.ClientCore
{
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;
//namespace NoSugarNet.ClientCore
//{
// 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;
}
// 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);
}
}
// 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);
// }
// }
/// <summary>
/// 通过下标发送
/// </summary>
/// <param name="Idx"></param>
/// <param name="data"></param>
public void SendSocketByIdx(int Idx, byte[] data)
{
if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo))
{
mSendAllLenght += data.Length;
SendToClient(_localClientInfo._socket, data);
}
//TODO连接前缓存数据
}
// /// <summary>
// /// 通过下标发送
// /// </summary>
// /// <param name="Idx"></param>
// /// <param name="data"></param>
// public void SendSocketByIdx(int Idx, byte[] data)
// {
// if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo))
// {
// mSendAllLenght += data.Length;
// SendToClient(_localClientInfo._socket, data);
// }
// //TODO连接前缓存数据
// }
/// <summary>
/// 接受包回调
/// </summary>
/// <param name="CMDID">协议ID</param>
/// <param name="ERRCODE">错误编号</param>
/// <param name="data">业务数据</param>
private void ReceiveData(Socket sk, byte[] data)
{
DataCallBack(sk, data);
}
// /// <summary>
// /// 接受包回调
// /// </summary>
// /// <param name="CMDID">协议ID</param>
// /// <param name="ERRCODE">错误编号</param>
// /// <param name="data">业务数据</param>
// 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<byte[]> _queue))
{
lock (_queue)
{
_queue.Enqueue(data);
while (_queue.Count > 0)
{
AppNoSugarNet.local.OnClientTunnelDataCallBack(mTunnelID, (byte)Idx, _queue.Dequeue());
}
}
}
// 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<byte[]> _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());
}
}
// ////抛出网络数据
// //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 CloseConnectByIdx(byte Idx)
// {
// if (GetSocketByIdx(Idx, out LocalClientInfo _localClientInf))
// {
// _localClientInf._socket.Shutdown(SocketShutdown.Both);
// }
// }
/// <summary>
/// 断开连接
/// </summary>
/// <param name="sk"></param>
public void OnDisconnectClient(Socket sk)
{
AppNoSugarNet.log.Info("断开连接");
// /// <summary>
// /// 断开连接
// /// </summary>
// /// <param name="sk"></param>
// public void OnDisconnectClient(Socket sk)
// {
// AppNoSugarNet.log.Info("断开连接");
if (!GetSocketIdxBySocket(sk, out int Idx))
return;
// if (!GetSocketIdxBySocket(sk, out int Idx))
// return;
AppNoSugarNet.local.OnClientLocalDisconnect(mTunnelID, (byte)Idx);
RemoveDictSocket(sk);
}
// AppNoSugarNet.local.OnClientLocalDisconnect(mTunnelID, (byte)Idx);
// RemoveDictSocket(sk);
// }
public void OnShowNetLog(string msg)
{
AppNoSugarNet.log.Info(msg);
}
// public void OnShowNetLog(string msg)
// {
// AppNoSugarNet.log.Info(msg);
// }
#region
Dictionary<nint, int> DictSocketHandle2Idx = new Dictionary<nint, int>();
Dictionary<nint, Queue<byte[]>> DictSocketHandle2Msg = new Dictionary<nint, Queue<byte[]>>();
Dictionary<int, LocalClientInfo> DictIdx2LocalClientInfo = new Dictionary<int, LocalClientInfo>();
int mSeedIdx = 0;
List<int> FreeIdxs = new List<int>();
public class LocalClientInfo
{
public Socket _socket;
public bool bRemoteConnect;
public bool bLocalConnect => _socket.Connected;
public Queue<IdxWithMsg> msgQueue = new Queue<IdxWithMsg>();
}
// #region 一个轻量级无用户连接管理
// Dictionary<nint, int> DictSocketHandle2Idx = new Dictionary<nint, int>();
// Dictionary<nint, Queue<byte[]>> DictSocketHandle2Msg = new Dictionary<nint, Queue<byte[]>>();
// Dictionary<int, LocalClientInfo> DictIdx2LocalClientInfo = new Dictionary<int, LocalClientInfo>();
// int mSeedIdx = 0;
// List<int> FreeIdxs = new List<int>();
// public class LocalClientInfo
// {
// public Socket _socket;
// public bool bRemoteConnect;
// public bool bLocalConnect => _socket.Connected;
// public Queue<IdxWithMsg> msgQueue = new Queue<IdxWithMsg>();
// }
int GetNextIdx()
{
if (FreeIdxs.Count > 0)
{
int Idx = FreeIdxs[0];
FreeIdxs.RemoveAt(0);
return Idx;
}
return mSeedIdx++;
}
// int GetNextIdx()
// {
// if (FreeIdxs.Count > 0)
// {
// int Idx = FreeIdxs[0];
// FreeIdxs.RemoveAt(0);
// return Idx;
// }
// return mSeedIdx++;
// }
/// <summary>
/// 追加Socket返回下标
/// </summary>
/// <param name="socket"></param>
/// <returns></returns>
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<byte[]>();
return Idx;
}
}
// /// <summary>
// /// 追加Socket返回下标
// /// </summary>
// /// <param name="socket"></param>
// /// <returns></returns>
// public int AddDictSocket(Socket socket)
// {
// if (socket == null)
// return -1;
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);
// lock (DictSocketHandle2Idx)
// {
// int Idx = GetNextIdx();
// DictSocketHandle2Idx[socket.Handle] = Idx;
// DictIdx2LocalClientInfo[Idx] = new LocalClientInfo() { _socket = socket,bRemoteConnect = false};
// DictSocketHandle2Msg[socket.Handle] = new Queue<byte[]>();
// AppNoSugarNet.log.Debug($"AddDictSocket mTunnelID->{mTunnelID} Idx->{Idx} socket.Handle{socket.Handle}");
// return Idx;
// }
// }
if (DictSocketHandle2Msg.ContainsKey(socket.Handle))
DictSocketHandle2Msg.Remove(socket.Handle);
// 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);
}
}
// if (DictSocketHandle2Msg.ContainsKey(socket.Handle))
// DictSocketHandle2Msg.Remove(socket.Handle);
bool GetSocketByIdx(int Idx, out LocalClientInfo _localClientInfo)
{
if (!DictIdx2LocalClientInfo.ContainsKey(Idx))
{
_localClientInfo = null;
return false;
}
// DictSocketHandle2Idx.Remove(socket.Handle);
_localClientInfo = DictIdx2LocalClientInfo[Idx];
return true;
}
// AppNoSugarNet.log.Debug($"RemoveDictSocket mTunnelID->{mTunnelID} Idx->{Idx} socket.Handle{socket.Handle}");
// }
// }
bool GetMsgQueueByIdx(nint handle, out Queue<byte[]> _queue)
{
if (!DictSocketHandle2Msg.ContainsKey(handle))
{
_queue = null;
return false;
}
// bool GetSocketByIdx(int Idx, out LocalClientInfo _localClientInfo)
// {
// if (!DictIdx2LocalClientInfo.ContainsKey(Idx))
// {
// _localClientInfo = null;
// return false;
// }
_queue = DictSocketHandle2Msg[handle];
return true;
}
// _localClientInfo = DictIdx2LocalClientInfo[Idx];
// return true;
// }
public bool GetSocketIdxBySocket(Socket _socket, out int Idx)
{
if (_socket == null)
{
Idx = -1;
return false;
}
// bool GetMsgQueueByIdx(nint handle, out Queue<byte[]> _queue)
// {
// if (!DictSocketHandle2Msg.ContainsKey(handle))
// {
// _queue = null;
// return false;
// }
if (!DictSocketHandle2Idx.ContainsKey(_socket.Handle))
{
Idx = -1;
return false;
}
// _queue = DictSocketHandle2Msg[handle];
// return true;
// }
Idx = DictSocketHandle2Idx[_socket.Handle];
return true;
}
// public bool GetSocketIdxBySocket(Socket _socket, out int Idx)
// {
// if (_socket == null)
// {
// Idx = -1;
// return false;
// }
public bool CheckRemoteConnect(int Idx)
{
if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo))
return false;
return _localClientInfo.bRemoteConnect;
}
// if (!DictSocketHandle2Idx.ContainsKey(_socket.Handle))
// {
// Idx = -1;
// return false;
// }
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;
}
// Idx = DictSocketHandle2Idx[_socket.Handle];
// return true;
// }
public void StopAll()
{
lock (DictIdx2LocalClientInfo)
{
int[] Idxs = DictIdx2LocalClientInfo.Keys.ToArray();
for (int i = 0; i < Idxs.Length; i++)
{
CloseConnectByIdx((byte)Idxs[i]);
}
DictIdx2LocalClientInfo.Clear();
}
}
// public bool CheckRemoteConnect(int Idx)
// {
// if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo))
// return false;
// return _localClientInfo.bRemoteConnect;
// }
#endregion
// 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();
// FreeIdxs.Clear();
// mSeedIdx = 0;
// }
// }
// #endregion
#region
public void EnqueueIdxWithMsg(byte Idx, byte[] data)
{
if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo))
return;
// #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<IdxWithMsg> MsgList)
{
if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo) || _localClientInfo.msgQueue.Count < 1)
{
MsgList = null;
return false;
}
// IdxWithMsg Msg = AppNoSugarNet.local._localMsgPool.Dequeue();
// Msg.Idx = Idx;
// Msg.data = data;
// _localClientInfo.msgQueue.Enqueue(Msg);
// }
// public bool GetDictMsgQueue(byte Idx,out List<IdxWithMsg> MsgList)
// {
// if (!GetSocketByIdx(Idx, out LocalClientInfo _localClientInfo) || _localClientInfo.msgQueue.Count < 1)
// {
// MsgList = null;
// return false;
// }
MsgList = new List<IdxWithMsg>();
lock (_localClientInfo.msgQueue)
{
while (_localClientInfo.msgQueue.Count > 0)
{
IdxWithMsg msg = _localClientInfo.msgQueue.Dequeue();
MsgList.Add(msg);
}
return true;
}
}
#endregion
}
}
// MsgList = new List<IdxWithMsg>();
// lock (_localClientInfo.msgQueue)
// {
// while (_localClientInfo.msgQueue.Count > 0)
// {
// IdxWithMsg msg = _localClientInfo.msgQueue.Dequeue();
// MsgList.Add(msg);
// }
// return true;
// }
// }
// #endregion
// }
//}

View File

@ -49,7 +49,7 @@ namespace NoSugarNet.ClientCore.Manager
//如果之前已登录,则重新登录
if (userdata.IsLoggedIn)
{
AppNoSugarNet.login.Login(userdata.Account);
AppNoSugarNet.login.Login();
}
}
}

View File

@ -33,7 +33,7 @@ namespace NoSugarNet.ClientCore.Network
/// <summary>
/// 是否自动重连
/// </summary>
public bool bAutoReConnect = false;
public bool bAutoReConnect = true;
/// <summary>
/// 重连尝试时间
/// </summary>
@ -44,12 +44,21 @@ namespace NoSugarNet.ClientCore.Network
NetworkDeBugLog($"NetworkConnected:{IsConnect}");
if (IsConnect)
{
AppNoSugarNet.login.Login(Guid.NewGuid().ToString());
//从未登录过
if (!AppNoSugarNet.user.IsLoggedIn)
{
//首次登录
AppNoSugarNet.login.Login();
}
}
else
{
//连接失败
NetworkDeBugLog("连接失败!");
//停止所有
AppNoSugarNet.local.StopAll();
//自动重连开关
if (bAutoReConnect)
ReConnect();

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2024-01-23T08:25:49.0876201Z;</History>
<History>True|2024-04-23T09:15:55.5521754Z;True|2024-01-23T16:25:49.0876201+08:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2024-01-25T09:08:35.3176032Z;</History>
<History>True|2024-04-23T09:13:21.9642037Z;True|2024-04-23T17:02:04.8137007+08:00;True|2024-01-25T17:08:35.3176032+08:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>D:\NoSugarNet\Sample\NoSugarNet.ClientCli\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
<_LastSelectedProfileId>F:\Sin365\NoSugarNet\Sample\NoSugarNet.ClientCli\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>

View File

@ -27,6 +27,12 @@ namespace NoSugarNet.ClientCli
case "con":
AppNoSugarNet.Connect(Config.ServerIP, Config.ServerPort);
break;
case "tlist":
AppNoSugarNet.local.GetClientCount(out int ClientUserCount, out int TunnelCount);
Console.WriteLine($"GetClientCount->{ClientUserCount} TunnelCount->{TunnelCount}");
AppNoSugarNet.local.GetClientDebugInfo();
break;
case "stop":
AppNoSugarNet.Close();
break;

View File

@ -6,12 +6,13 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net8.0\publish\linux-x64\</PublishDir>
<PublishDir>bin\Release\net8.0\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
</Project>

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2024-04-14T14:24:49.2846754Z;True|2024-01-23T16:35:06.3918472+08:00;True|2024-01-23T16:34:52.0595483+08:00;True|2024-01-23T16:27:36.4850749+08:00;True|2024-01-23T16:27:04.0721589+08:00;</History>
<History>True|2024-06-18T04:59:35.6257454Z;True|2024-06-18T10:27:07.8233386+08:00;True|2024-06-17T15:05:24.3158316+08:00;True|2024-05-20T18:14:09.8394409+08:00;True|2024-05-20T18:13:33.8442145+08:00;True|2024-05-20T18:01:49.3220793+08:00;True|2024-05-20T18:01:28.3681468+08:00;True|2024-04-14T22:24:49.2846754+08:00;True|2024-01-23T16:35:06.3918472+08:00;True|2024-01-23T16:34:52.0595483+08:00;True|2024-01-23T16:27:36.4850749+08:00;True|2024-01-23T16:27:04.0721589+08:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2024-04-15T07:24:50.3598281Z;True|2024-04-15T15:24:34.0374231+08:00;True|2024-01-25T17:09:07.9161603+08:00;True|2024-01-23T18:28:01.1220581+08:00;True|2024-01-23T16:36:21.1141328+08:00;</History>
<History>True|2024-06-18T03:37:53.3986849Z;True|2024-06-18T11:21:56.8035265+08:00;True|2024-06-18T11:21:19.5434721+08:00;True|2024-06-18T11:21:01.1589956+08:00;True|2024-06-18T11:13:38.3624463+08:00;True|2024-06-18T11:10:28.0508856+08:00;True|2024-06-18T10:39:23.0033920+08:00;True|2024-06-18T10:28:08.9658896+08:00;True|2024-06-17T14:46:33.2307641+08:00;True|2024-05-20T17:56:34.6581491+08:00;True|2024-04-23T17:02:36.4793408+08:00;True|2024-04-15T15:24:50.3598281+08:00;True|2024-04-15T15:24:34.0374231+08:00;True|2024-01-25T17:09:07.9161603+08:00;True|2024-01-23T18:28:01.1220581+08:00;True|2024-01-23T16:36:21.1141328+08:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>