public function send($action, array $data = array())
    {
        $message = array('action' => $action);

        if (count($data) > 0) {
            $message['data'] = $data;
        }

        $message = json_encode($message);

        $this->connect();
        $this->connection->writeText($message);
        $this->disconnect();

        return $this;
    }