Преглед на файлове

Update SerializeTrait.php

mouyong преди 3 години
родител
ревизия
bcb302abd3
променени са 1 файла, в които са добавени 9 реда и са изтрити 3 реда
  1. 9 3
      src/Connection/Traits/SerializeTrait.php

+ 9 - 3
src/Connection/Traits/SerializeTrait.php

@@ -18,10 +18,16 @@ trait SerializeTrait
 {
     public function jsonSerialize()
     {
-        return [
+        $data = [];
+        if ($this->transport === 'tcp') {
+            $data = [
+                'id' => $this->id,
+                'status' => $this->getStatus(),
+            ];
+        }
+        
+        return $data + [
             'transport' => $this->transport,
-            'id' => $this->id,
-            'status' => $this->getStatus(),
             'getRemoteIp' => $this->getRemoteIp(),
             'remotePort' => $this->getRemotePort(),
             'getRemoteAddress' => $this->getRemoteAddress(),