From 09e9bf74a16d985e3a16c43b0661eb7d669d0958 Mon Sep 17 00:00:00 2001 From: Daniel Rampanelli Date: Fri, 2 Dec 2016 22:44:29 +0100 Subject: [PATCH] Clean up the list of clients by removing dead/invalid connections. --- src/Application/ServerApplication.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Application/ServerApplication.php b/src/Application/ServerApplication.php index cb5043f..e5b2fbf 100644 --- a/src/Application/ServerApplication.php +++ b/src/Application/ServerApplication.php @@ -107,10 +107,15 @@ public function addClient(Protocol\LivereloadProtocol $client) public function removeClient(Protocol\LivereloadProtocol $client) { + $this->clients = array_values(array_filter($this->clients, function($client) { + return !empty($client->app) && !empty($client->conn); + })); + $index = array_search($client, $this->clients, true); if($index == false){ return; } + unset($this->clients[$index]); }