Skip to content

Commit

Permalink
add log and ping_time
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Oct 27, 2020
1 parent a939148 commit d19817a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Api/WebSocket/SocketServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,16 @@ private function onMessage($global){

private function onClose(){
return function($con){
$this->log('reconnection');

//这里连接失败 会轮询 connect
$con->reConnect(5);
};
}

private function onError(){
return function($con, $code, $msg){

$this->log('onerror code:'.$code.' msg:'.$msg);
};
}

Expand All @@ -150,7 +152,7 @@ private function connect($con){
private function ping($con){
$time=isset($this->config['ping_time']) ? $this->config['ping_time'] : 20 ;

Timer::add(20, function() use ($con) {
Timer::add($time, function() use ($con) {
$con->send("ping");

$this->log($con->tag.' send ping');
Expand Down

0 comments on commit d19817a

Please sign in to comment.