Parcourir la source

Update TcpConnection.php

mouyong il y a 3 ans
Parent
commit
169f6f96d5
1 fichiers modifiés avec 18 ajouts et 3 suppressions
  1. 18 3
      src/Connection/TcpConnection.php

+ 18 - 3
src/Connection/TcpConnection.php

@@ -21,10 +21,8 @@ use Workerman\Worker;
 /**
  * TcpConnection.
  */
-class TcpConnection extends ConnectionInterface implements \JsonSerializable, \Serializable
+class TcpConnection extends ConnectionInterface implements \JsonSerializable
 {
-    use Traits\SerializeTrait;
-
     /**
      * Read buffer size.
      *
@@ -971,6 +969,23 @@ class TcpConnection extends ConnectionInterface implements \JsonSerializable, \S
     {
         static::$_enableCache = (bool)$value;
     }
+    
+    public function jsonSerialize()
+    {        
+        return [
+            'id' => $this->id,
+            'status' => $this->getStatus(),
+            'transport' => $this->transport,
+            'getRemoteIp' => $this->getRemoteIp(),
+            'remotePort' => $this->getRemotePort(),
+            'getRemoteAddress' => $this->getRemoteAddress(),
+            'getLocalIp' => $this->getLocalIp(),
+            'getLocalPort' => $this->getLocalPort(),
+            'getLocalAddress' => $this->getLocalAddress(),
+            'isIpV4' => $this->isIpV4(),
+            'isIpV6' => $this->isIpV6(),
+        ];
+    }
 
     /**
      * Destruct.