From 8521357663b835785e1e1c053b7078fa1cc0ec7d Mon Sep 17 00:00:00 2001 From: adamzul Date: Sat, 8 Feb 2020 15:37:03 +0700 Subject: [PATCH 1/5] skip handshake if using websocket as transport. websocket transport is use full if socket server multi node and not stick. --- src/Engine/SocketIO/Version1X.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Engine/SocketIO/Version1X.php b/src/Engine/SocketIO/Version1X.php index ea2d7ef..391d765 100644 --- a/src/Engine/SocketIO/Version1X.php +++ b/src/Engine/SocketIO/Version1X.php @@ -42,7 +42,9 @@ public function connect() return; } - $this->handshake(); + if($this->options['transport'] != 'websocket'){ + $this->handshake(); + } $protocol = 'http'; $errors = [null, null]; @@ -239,7 +241,7 @@ protected function handshake() */ protected function upgradeTransport() { - $query = ['sid' => $this->session->id, + $query = ['sid' => $this->session->id ? $this->session->id : null, 'EIO' => $this->options['version'], 'transport' => static::TRANSPORT_WEBSOCKET]; From 38916a9fd16bd8f5fac8ce4c80b59b8e2c606f35 Mon Sep 17 00:00:00 2001 From: adam zulkarnain Date: Sun, 9 Feb 2020 19:04:17 +0700 Subject: [PATCH 2/5] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f37dc89..4d65a29 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "wisembly/elephant.io", + "name": "adamzul/elephant.io", "type": "library", "description": "Send events to a websocket real time engine though PHP", "keywords": ["Nodejs", "WebSocket", "Dialog", "Real Time"], From 7c42f340b3bae618159b522d9249f406e78e1651 Mon Sep 17 00:00:00 2001 From: adam zulkarnain Date: Sun, 9 Feb 2020 19:05:10 +0700 Subject: [PATCH 3/5] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4d65a29..0447b89 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "adamzul/elephant.io", + "name": "Wisembly/elephant.io", "type": "library", "description": "Send events to a websocket real time engine though PHP", "keywords": ["Nodejs", "WebSocket", "Dialog", "Real Time"], From 9008bd192487549a9dc9b960e9d4bacb833737b2 Mon Sep 17 00:00:00 2001 From: adam zulkarnain Date: Sun, 9 Feb 2020 19:11:24 +0700 Subject: [PATCH 4/5] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0447b89..f37dc89 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "Wisembly/elephant.io", + "name": "wisembly/elephant.io", "type": "library", "description": "Send events to a websocket real time engine though PHP", "keywords": ["Nodejs", "WebSocket", "Dialog", "Real Time"], From cc726ff17f0a96bc2118ba1b7810b0111cf0b203 Mon Sep 17 00:00:00 2001 From: adam zulkarnain Date: Sun, 9 Feb 2020 19:18:16 +0700 Subject: [PATCH 5/5] fixing if session id not found --- src/Engine/SocketIO/Version1X.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Engine/SocketIO/Version1X.php b/src/Engine/SocketIO/Version1X.php index 391d765..d65f73e 100644 --- a/src/Engine/SocketIO/Version1X.php +++ b/src/Engine/SocketIO/Version1X.php @@ -241,7 +241,7 @@ protected function handshake() */ protected function upgradeTransport() { - $query = ['sid' => $this->session->id ? $this->session->id : null, + $query = ['sid' => isset($this->session->id) ? $this->session->id : null, 'EIO' => $this->options['version'], 'transport' => static::TRANSPORT_WEBSOCKET]; @@ -310,8 +310,10 @@ protected function upgradeTransport() */ public function keepAlive() { - if ($this->session->needsHeartbeat()) { - $this->write(static::PING); + if($this->session){ + if ($this->session->needsHeartbeat()) { + $this->write(static::PING); + } } } }