lith vor 3 Jahren
Ursprung
Commit
e3c3bd0573

+ 1 - 1
dotnet/Library/Sers/Sers.Core/Sers.Core/CL/MessageOrganize/DefaultOrganize/Extensions/IOrganizeConnectionExtensions.cs

@@ -8,7 +8,7 @@ namespace Vit.Extensions
     {
 
         [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
-        internal static IDeliveryConnection GetDeliveryConn(this IOrganizeConnection data)
+        public static IDeliveryConnection GetDeliveryConn(this IOrganizeConnection data)
         {
             return (data as OrganizeConnection)?.deliveryConn;
         }

+ 5 - 1
dotnet/ServiceCenter/App.Gover.Gateway/wwwroot/_gover_/ServiceStation.html

@@ -128,7 +128,7 @@
                     <script src="Scripts/Sers/sers.apiClient.js"></script>
                     <div id="stations">
 
-                        <div v-for="station in stations" style="width:300px;height:520px;line-height:1.5;float:left;margin:2px;padding:4px;word-wrap:break-word;" class="line">
+                        <div v-for="station in stations" style="width:300px;height:520px;line-height:1.4;float:left;margin:2px;padding:4px;word-wrap:break-word;" class="line">
                             <font style="font-weight:bold;color:#e84855;">{{ (station.serviceStationInfo||{}).serviceStationName }} </font><br />
                             {{station.apiStationNames}} <br />
                             操作 : <a @click="start(station)">打开</a>   <a @click="pause(station)">暂停</a>  <a @click="stop(station)">强制关闭</a>
@@ -206,6 +206,10 @@
                                     <td> connKey </td>
                                     <td> : <font :title="station.connKey">{{(station.connKey||'').substr(0,4) }} </font></td>
                                 </tr>
+                                <tr>
+                                    <td> connectionIp </td>
+                                    <td> : <font :title="station.connectionIp">{{ station.connectionIp }} </font></td>
+                                </tr>
                             </table>
                             <br /> <!--{{station.deviceInfo}}-->
                         </div>

+ 9 - 0
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/Model/ServiceStationData.cs

@@ -13,6 +13,15 @@ namespace Sers.Gover.Base.Model
     {
         public string connKey { get; set; }
 
+
+        /// <summary>
+        /// 连接客户端的ip
+        /// </summary>
+        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+        public string connectionIp;
+
+
+
         /// <summary>
         /// 服务站点开启时间
         /// </summary>

+ 1 - 0
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.Gover/Base/ServiceStationMng.cs

@@ -59,6 +59,7 @@ namespace Sers.Gover.Base
                     m => new ServiceStationData
                     {
                         connKey = "" + m.connection.GetHashCode(),
+                        connectionIp = m.connectionIp,
                         startTime = m.startTime,
                         deviceInfo = m.deviceInfo,
                         serviceStationInfo = m.serviceStationInfo,

+ 39 - 3
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter/Controllers/ServiceStationController.cs

@@ -6,6 +6,10 @@ using Sers.ServiceCenter.Entity;
 using Vit.Core.Util.ComponentModel.Api;
 using Vit.Core.Util.ComponentModel.Data;
 using Vit.Core.Util.ComponentModel.Model;
+using Vit.Extensions;
+using System.Net.WebSockets;
+using System.Net;
+using System;
 
 namespace Sers.ServiceCenter.Controllers
 {
@@ -21,15 +25,47 @@ namespace Sers.ServiceCenter.Controllers
         [SsName("注册站点")]
         [SsCallerSource(ECallerSource.Internal)]
         public ApiReturn Regist(ServiceStation serviceStation)
-        {  
+        {
             serviceStation.connection = CommunicationManageServer.CurConn;
 
-            if(serviceStation.connection!=null)
+            if (serviceStation.connection != null)
                 serviceStation.connection.connTag = serviceStation?.serviceStationInfo?.serviceStationName;
 
+            #region (x.2)获取客户端ip地址
+            try
+            {
+                if (serviceStation.connection != null)
+                {
+                    var deliveryConn = serviceStation.connection.GetDeliveryConn();
+                    global::System.Net.Sockets.Socket socket = null;
+
+                    if (deliveryConn is Sers.CL.Socket.ThreadWait.DeliveryConnection conn_threadWait)
+                    {
+                        socket = conn_threadWait.socket;
+                    }
+                    else if (deliveryConn is Sers.CL.Socket.Iocp.Base.DeliveryConnection_Base conn_Iocp)
+                    {
+                        socket = conn_Iocp.socket;
+                    }
+
+                    if (socket != null)
+                    {
+                        IPEndPoint clientPoint = (IPEndPoint)socket.RemoteEndPoint;
+                        string clientIp = clientPoint.Address.ToString();
+                        serviceStation.connectionIp = clientIp;
+                    }
+                }
+            }
+            catch (System.Exception)
+            {
+            }
+            #endregion
+
+
+
             //注册站点       
             ServiceCenter.Instance.apiCenterService.ServiceStation_Regist(serviceStation);
-            return true;            
+            return true;
         }
 
 

+ 6 - 0
dotnet/ServiceCenter/Sers.ServiceCenter/Sers.ServiceCenter/Entity/ServiceStation.cs

@@ -36,6 +36,12 @@ namespace Sers.ServiceCenter.Entity
         [JsonIgnore]
         public IOrganizeConnection connection { get; set; }
 
+        /// <summary>
+        /// 连接客户端的ip
+        /// </summary>
+        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+        public string connectionIp;
+
         /// <summary>
         /// 站点软硬件环境信息
         /// </summary>