/** * Main loop, catches messages and then dispatches them */ public function start() { $keepAlive = true; while (ConnectionManager::connected() && $keepAlive) { try { $Msg = ConnectionManager::receive(); if ($Msg) { $this->beforeMessage($Msg); $this->onMessage($Msg); //need a call to the dispatcher here $this->afterMessage($Msg); } } catch (Exception $e) { echo "oi! WTF! {$e} \n"; } } ConnectionManager::disconnect(); }