sendMessage(msg, options = {}) {
        return new Promise((resolve, reject) => {
            this.mutex.take(() => {
                this.sendMessageHelper(msg, options).then(response => {

                    this.mutex.leave();
                    resolve(response);
                }).catch(err => {

                    this.mutex.leave();
                    reject(err);
                });
            });
        });
    }
Sends a message on the MiioSocket.
Performs multiple retries on timeout and also does a handshake if this wasn't yet done on the connection.

Will block and wait for an existing request to finish if there is one

@param {object?} msg JSON object to send to remote
@param {object} options
@param {number=} options.retries
@param {number=} options.timeout custom timeout in milliseconds
@returns {Promise<object>}