From 2fbb51dcd416d4d398b67bc0a78901095ba42c66 Mon Sep 17 00:00:00 2001 From: kremsy Date: Tue, 23 Jun 2015 15:44:22 +0200 Subject: [PATCH] some cleanup --- core/Communication/Communication.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/Communication/Communication.php b/core/Communication/Communication.php index 72813003..d8ae80c9 100644 --- a/core/Communication/Communication.php +++ b/core/Communication/Communication.php @@ -47,11 +47,10 @@ class Communication { * @param callable $function * @param $method * @param string $data - * @return null */ public function call(callable $function, $method, $data = "") { - //TODO throw an exception or smth if (!$this->socket) { + call_user_func($function, true, "You need to create an Communication before using it"); return null; } @@ -69,6 +68,11 @@ class Communication { * Process data on every Tick */ public function tick() { + //Check if the connection is enabled + if (!$this->socket) { + return; + } + $data = fgets($this->socket, 1024); // reads as much as possible OR nothing at all if (strlen($data) > 0) { // got new data $this->buffer .= $data; // append new data to buffer