yingzi 2 years ago
parent
commit
c284ca03c7
1 changed files with 9 additions and 20 deletions
  1. 9 20
      Mall/Framework/Swoole/WebsocketClient.Class.php

+ 9 - 20
Mall/Framework/Swoole/WebsocketClient.Class.php

@@ -70,7 +70,7 @@ class WebSocketClient
         $this->path = $path;
         $this->key = $this->generateToken(self::TOKEN_LENGHT);
         $this->parser = new WebsocketParser();
-var_dump($options);
+
         if($options['ssl'] == true){
             self::enableCrypto($options['ssl_key_file'], $options['ssl_cert_file']);
         }
@@ -116,28 +116,18 @@ var_dump($options);
     {
         if (extension_loaded('swoole'))
         {
-            var_dump("xxaa02");
-//            $type = SWOOLE_TCP;
-//            if ($this->ssl)
-//            {
-//                $type |= SWOOLE_SSL;
-//            }
-//            $this->socket = new \swoole_client($type);
-            if($this->ssl){
-                $this->socket = new \swoole_client(SWOOLE_SOCK_TCP | SWOOLE_SSL);
-            }else{
-                $this->socket = new \swoole_client(SWOOLE_SOCK_TCP);
+            $type = SWOOLE_TCP;
+            if ($this->ssl)
+            {
+                $type |= SWOOLE_SSL;
             }
-            
-            
-            var_dump("xxaa03");
-            var_dump($this->ssl_cert_file);
-            var_dump($this->ssl_key_file);
-            var_dump($this->ssl);
+            $this->socket = new \swoole_client($type);
             if ($this->ssl_key_file)
             {
+                var_dump($this->ssl_key_file);
                 var_dump($this->ssl_cert_file);
-                var_dump("xxaa");
+                var_dump(file_exists($this->ssl_key_file));
+                var_dump(file_exists($this->ssl_cert_file));
                 $this->socket->set(array(
                     'ssl_key_file' => $this->ssl_key_file,
                     'ssl_cert_file' => $this->ssl_cert_file,
@@ -152,7 +142,6 @@ var_dump($options);
         else
         {
             $this->socket = new \TCP;
-            var_dump("xxaa01");
         }
         //建立连接
         if (!$this->socket->connect($this->host, $this->port, $timeout))