/// <summary> /// 获取已连接成功的客户端信息 /// </summary> private void GetClientInfo() { try { if (server != null) { InternalLogger.Log.Info("已连接成功的客户端个数为" + server.GetSessionCollection().Count); foreach (var item in server.GetSessionCollection().Keys) { this.sessionId = item; server.GetSessionCollection().TryGetValue(item, out this.currentClient); } } } catch (Exception ex) { InternalLogger.Log.Error("获取已连接成功的客户端信息出错:" + ex.Message); } }
/// <summary> /// 获取已连接成功的客户端信息 /// </summary> static void GetClientInfo() { try { if (tcpServer != null) { foreach (var item in tcpServer.GetSessionCollection().Keys) { sessionId = item; break; } } } catch (Exception ex) { Console.WriteLine(ex); } }