Пример #1
0
 /**
  * Receives data sent by the server
  *
  * @return array<Payload> Payload received since the last call to receive()
  */
 public function receive()
 {
     if (!$this->isConnected()) {
         return false;
     }
     $data = $this->socket->receive();
     if (!$data) {
         return $data;
     }
     $old = $this->received;
     $this->payloadHandler->handle($data);
     return array_diff_assoc($this->received, $old);
 }
Пример #2
0
 /**
  * Handle data received from the client
  *
  * The data passed in may belong to several different frames across one or
  * more protocols. It may not even contain a single complete frame. This method
  * manages slotting the data into separate payload objects.
  *
  * @todo An endpoint MUST be capable of handling control frames in the
  *        middle of a fragmented message.
  * @param string $data
  * @return void
  */
 public function handle($data)
 {
     $this->payloadHandler->handle($data);
 }