/**
  * Initialize your logic and do whatever you want external
  * @param ThreadCommunicator $communicator
  */
 public function InitializeExternal(ThreadCommunicator $communicator)
 {
     $communicator->getLoop()->addReadStream($this->stream, function ($stream) {
         $message = fgets($stream, 1024);
         //calling the EventEmiiter::emit() function on parent
         $this->callOnParent('emit', array('stream_message', array($message)));
     });
 }
 /**
  * @return float
  */
 public function getSecondsSinceLastMessage()
 {
     return $this->communicator->getSecondsSinceLastMessage();
 }
 /**
  * Initialize your logic and do whatever you want external
  * @param ThreadCommunicator $communicator
  */
 public function InitializeExternal(ThreadCommunicator $communicator)
 {
     //save the loop to create fatal
     $this->loop = $communicator->getLoop();
     //we will kill the thread by exeptions and fatals
 }