Skip to content
This repository was archived by the owner on Sep 7, 2019. It is now read-only.

Receive server pong by client ping #96

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Devristo/Phpws/Client/WebSocket.php
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions src/Devristo/Phpws/Protocol/WebSocketTransportHybi.php
Original file line number Diff line number Diff line change
@@ -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 {