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) 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 {