src/LiveDevelopment/Inspector/Inspector.js
function _send(method, signature, varargs) {
        if (!_socket) {
            console.log("You must connect to the WebSocket before sending messages.");

            // FUTURE: Our current implementation closes and re-opens an inspector connection whenever
            // a new HTML file is selected. If done quickly enough, pending requests from the previous
            // connection could come in before the new socket connection is established. For now we
            // simply ignore this condition.
            // This race condition will go away once we support multiple inspector connections and turn
            // off auto re-opening when a new HTML file is selected.
            return (new $.Deferred()).reject().promise();
        }

        var id, callback, args, i, params = {}, promise, msg;

        // extract the parameters, the callback function, and the message id
        args = Array.prototype.slice.call(arguments, 2);
        if (typeof args[args.length - 1] === "function") {
            callback = args.pop();
        } else {
            var deferred = new $.Deferred();
            promise = deferred.promise();
            callback = function (result, error) {
                if (error) {
                    deferred.reject(error);
                } else {
                    deferred.resolve(result);
                }
            };
        }

        id = _messageId++;

        // verify the parameters against the method signature
        // this also constructs the params object of type {name -> value}
        if (signature) {
            for (i in signature) {
                if (_verifySignature(args[i], signature[i])) {
                    params[signature[i].name] = args[i];
                }
            }
        }

        // Store message callback and send message
        msg = { method: method, id: id, params: params };
        _messageCallbacks[id] = { callback: callback, message: msg };
        _socket.send(JSON.stringify(msg));

        return promise;
    }
function _send(method, signature, varargs) {
        if (!_socket) {
            console.log("You must connect to the WebSocket before sending messages.");

            // FUTURE: Our current implementation closes and re-opens an inspector connection whenever
            // a new HTML file is selected. If done quickly enough, pending requests from the previous
            // connection could come in before the new socket connection is established. For now we
            // simply ignore this condition.
            // This race condition will go away once we support multiple inspector connections and turn
            // off auto re-opening when a new HTML file is selected.
            return (new $.Deferred()).reject().promise();
        }

        var id, callback, args, i, params = {}, promise, msg;

        // extract the parameters, the callback function, and the message id
        args = Array.prototype.slice.call(arguments, 2);
        if (typeof args[args.length - 1] === "function") {
            callback = args.pop();
        } else {
            var deferred = new $.Deferred();
            promise = deferred.promise();
            callback = function (result, error) {
                if (error) {
                    deferred.reject(error);
                } else {
                    deferred.resolve(result);
                }
            };
        }

        id = _messageId++;

        // verify the parameters against the method signature
        // this also constructs the params object of type {name -> value}
        if (signature) {
            for (i in signature) {
                if (_verifySignature(args[i], signature[i])) {
                    params[signature[i].name] = args[i];
                }
            }
        }

        // Store message callback and send message
        msg = { method: method, id: id, params: params };
        _messageCallbacks[id] = { callback: callback, message: msg };
        _socket.send(JSON.stringify(msg));

        return promise;
    }
function _send ( method , signature , varargs ) { if ( ! _socket ) { console . log ( "You must connect to the WebSocket before sending messages." ) ; // FUTURE: Our current implementation closes and re-opens an inspector connection whenever // a new HTML file is selected. If done quickly enough, pending requests from the previous // connection could come in before the new socket connection is established. For now we // simply ignore this condition. // This race condition will go away once we support multiple inspector connections and turn // off auto re-opening when a new HTML file is selected. return ( new $ . Deferred ( ) ) . reject ( ) . promise ( ) ; } var id , callback , args , i , params = { } , promise , msg ; // extract the parameters, the callback function, and the message id args = Array . prototype . slice . call ( arguments , 2 ) ; if ( typeof args [ args . length - 1 ] === "function" ) { callback = args . pop ( ) ; } else { var deferred = new $ . Deferred ( ) ; promise = deferred . promise ( ) ; callback = function ( result , error ) { if ( error ) { deferred . reject ( error ) ; } else { deferred . resolve ( result ) ; } } ; } id = _messageId ++ ; // verify the parameters against the method signature // this also constructs the params object of type {name -> value} if ( signature ) { for ( i in signature ) { if ( _verifySignature ( args [ i ] , signature [ i ] ) ) { params [ signature [ i ] . name ] = args [ i ] ; } } } // Store message callback and send message msg = { method : method , id : id , params : params } ; _messageCallbacks [ id ] = { callback : callback , message : msg } ; _socket . send ( JSON . stringify ( msg ) ) ; return promise ; }
Send a message to the remote debugger
All passed arguments after the signature are passed on as parameters.
If the last argument is a function, it is used as the callback function.
@param {string} remote method
@param {object} the method signature
Send a message to the remote debugger All passed arguments after the signature are passed on as parameters . If the last argument is a function it is used as the callback function .