public function send($packets) { foreach ($packets as $packet) { $data = Parser::encodePacket($packet, $this->supportsBinary); $this->socket->send($data); $this->emit('drain'); } }
public function send($packets) { $this->writable = false; if ($this->shouldClose) { echo 'appending close packet to payload'; $packets[] = array('type' => 'close'); call_user_func($this->shouldClose); $this->shouldClose = null; } $data = Parser::encodePayload($packets, $this->supportsBinary); $this->write($data); }
public function onData($data) { $this->onPacket(Parser::decodePacket($data)); }