From 227337207895e7cb57a472070cb91e7d329b0745 Mon Sep 17 00:00:00 2001 From: yura999999999 Date: Mon, 27 Mar 2017 14:21:59 +0300 Subject: [PATCH 1/2] Update WebSocket.php --- src/Devristo/Phpws/Client/WebSocket.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Devristo/Phpws/Client/WebSocket.php b/src/Devristo/Phpws/Client/WebSocket.php index 949529c..11c5a11 100644 --- a/src/Devristo/Phpws/Client/WebSocket.php +++ b/src/Devristo/Phpws/Client/WebSocket.php @@ -141,6 +141,10 @@ public function open($timeOut=null) $that->emit("message", array("message" => $message)); }); + $transport->on("pong", function($frame) use($that){ + $that->emit("pong", array("frame" => $frame)); + }); + $transport->initiateHandshake($uri); $that->state = WebSocket::STATE_HANDSHAKE_SENT; }, function($reason) use ($that, $deferred) From 35ea355c438e90cbc7890a0520c3215c1f564d0c Mon Sep 17 00:00:00 2001 From: yura999999999 Date: Mon, 27 Mar 2017 14:23:12 +0300 Subject: [PATCH 2/2] Update WebSocketTransportHybi.php --- src/Devristo/Phpws/Protocol/WebSocketTransportHybi.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Devristo/Phpws/Protocol/WebSocketTransportHybi.php b/src/Devristo/Phpws/Protocol/WebSocketTransportHybi.php index 29eea9a..df9c697 100644 --- a/src/Devristo/Phpws/Protocol/WebSocketTransportHybi.php +++ b/src/Devristo/Phpws/Protocol/WebSocketTransportHybi.php @@ -173,9 +173,16 @@ protected function processControlFrame(WebSocketFrame $frame) $frame = WebSocketFrame::create(WebSocketOpcode::PongFrame, $frame->getData()); $this->sendFrame($frame); break; + case WebSocketOpcode::PongFrame : + $this->receivePongFrame($frame); + break; } } + public function receivePongFrame($frame) { + $this->emit("pong", array($frame)); + } + public function sendString($msg) { try {