stanley-king 4 роки тому
батько
коміт
d70e36f2cb
2 змінених файлів з 23 додано та 2 видалено
  1. 16 0
      test/TestRefill.php
  2. 7 2
      wsd_bridge.php

+ 16 - 0
test/TestRefill.php

@@ -208,6 +208,22 @@ class TestRefill extends TestCase
         }
     }
 
+    public function testProxyHelper()
+    {
+        $phone = '13911129867';
+        $amount = 100;
+        $url = $this->mReqHost . "/mobile/index.php";
+        $params = ['mchid' => 1090,
+            'cardno' => $phone,
+            'amount' => $amount,
+            "act"=>"refill",
+            "op"=>"add",
+            'order_sn' => $this->make_sn(),
+            'notifyurl'=> "https://qzcz.edusahoo.com.cn/index/index/callback"];
+         $proxy = new refill_proxy("ZhongFKJZhongFKJZhongFKJ");
+         $resp = $proxy->send($url,$params);
+    }
+
     public function testGoods()
     {
         $req_url = $this->mReqHost . '/mobile/index.php';

+ 7 - 2
wsd_bridge.php

@@ -35,15 +35,20 @@ class WSDBridge
 
         while (true)
         {
-            if (($client = socket_accept($fd)) !== false) {
+            Log::record("Waitting another connect....");
+            if (($client = socket_accept($fd)) !== false)
+            {
                 Log::record("Client {$client} has connected", Log::DEBUG);
                 socket_set_option($client, SOL_SOCKET, SO_RCVTIMEO, ['sec' => 8, 'usec' => 0]);
 
                 $body = $this->read_order($client);
-                if($body !== false) {
+                if($body !== false && !empty($body)) {
+                    Log::record("req:{$body}",Log::DEBUG);
                     $response = $this->relay_request($body);
                     socket_write($client,$response);
+                    Log::record("resp:{$response}",Log::DEBUG);
                 }
+                
                 socket_close($client);
             }
         }