Kaynağa Gözat

1. fix get result before fail check
2. add back missing code

Robert 2 yıl önce
ebeveyn
işleme
6f1f9ac686

+ 16 - 0
EVCB_OCPP.WSServer/GlobalConfig.cs

@@ -10,6 +10,8 @@ namespace EVCB_OCPP.WSServer
     {
         public static List<string> ConfigKeys = new List<string>()
         {
+            "WSPort",
+            "WSSPort",
             "OCPP20_WSUrl",
             "OCPP20_WSSUrl"
         };
@@ -61,6 +63,20 @@ namespace EVCB_OCPP.WSServer
                     key = ConfigKeys[i];
                     switch (key)
                     {
+                        case "WSPort":// convert to int type                       
+                            {
+                                var value = configuration[key];
+
+                                WS_Port = string.IsNullOrEmpty(value) ? WS_Port : Convert.ToInt32(value);
+                            }
+                            break;
+                        case "WSSPort":
+                            {
+                                var value = configuration[key];
+
+                                WSS_Port = string.IsNullOrEmpty(value) ? WS_Port : Convert.ToInt32(value);
+                            }
+                            break;
                         case "OCPP20_WSUrl":// convert to int type                       
                             {
                                 var value = configuration[key];

+ 1 - 0
EVCB_OCPP.WSServer/ProtalServer.cs

@@ -557,6 +557,7 @@ namespace EVCB_OCPP.WSServer
             //設定server config
             var serverConfig = new ServerConfig
             {
+                SendingQueueSize = 10,
                 //Port = Convert.ToInt32(2012),
                 //Ip = "172.17.40.13",
                 MaxRequestLength = 204800,

+ 2 - 0
EVCB_OCPP.WSServer/appsettings.json

@@ -1,4 +1,6 @@
 {
+  "WSPort": 80,
+  "WSSPort": 443,
   "LocalAuthAPI": "",
   "OCPP20_WSUrl": "ws://ocpp.phihong.com.tw:5004",
   "OCPP20_WSSUrl": "ws://ocpp.phihong.com.tw:5004",

+ 1 - 2
SocketEngine/AsyncStreamSocketSession.cs

@@ -112,8 +112,6 @@ namespace SuperSocket.SocketEngine
 
         private void OnStreamEndRead(Task<int> task,Stream stream)
         {
-            int thisRead = task.Result;
-
             if (task.IsFaulted || task.Exception is not null)
             {
                 LogError(task.Exception);
@@ -121,6 +119,7 @@ namespace SuperSocket.SocketEngine
                 return;
             }
 
+            int thisRead = task.Result;
             if (thisRead <= 0)
             {
                 OnReceiveTerminated(CloseReason.ClientClosing);