src/simple-mqtt-client/client-browser.js
function(client, subscriptions, backlog, channel, callback, done_callback) {
    if ( addToBacklog(client, backlog, unsubscribeBrowser, [client, subscriptions, backlog, channel, callback, done_callback]) ) return;
    if (subscriptions[channel]===undefined)
        return;
    subscriptions[channel].splice(subscriptions[channel].indexOf(callback), 1);
    if (subscriptions[channel].length===0) {
        delete subscriptions[channel];
        client.unsubscribe(channel, {onSuccess : function() {
            // If there is a done_callback defined, execute it
            if (done_callback!==undefined) done_callback();
        }});
    }
}
function(client, subscriptions, backlog, channel, callback, done_callback) {
    if ( addToBacklog(client, backlog, unsubscribeBrowser, [client, subscriptions, backlog, channel, callback, done_callback]) ) return;
    if (subscriptions[channel]===undefined)
        return;
    subscriptions[channel].splice(subscriptions[channel].indexOf(callback), 1);
    if (subscriptions[channel].length===0) {
        delete subscriptions[channel];
        client.unsubscribe(channel, {onSuccess : function() {
            // If there is a done_callback defined, execute it
            if (done_callback!==undefined) done_callback();
        }});
    }
}
function ( client , subscriptions , backlog , channel , callback , done_callback ) { if ( addToBacklog ( client , backlog , unsubscribeBrowser , [ client , subscriptions , backlog , channel , callback , done_callback ] ) ) return ; if ( subscriptions [ channel ] === undefined ) return ; subscriptions [ channel ] . splice ( subscriptions [ channel ] . indexOf ( callback ) , 1 ) ; if ( subscriptions [ channel ] . length === 0 ) { delete subscriptions [ channel ] ; client . unsubscribe ( channel , { onSuccess : function ( ) { // If there is a done_callback defined, execute it if ( done_callback !== undefined ) done_callback ( ) ; } } ) ; } }
Helper function that unsubscribes from a channel in the browser
Helper function that unsubscribes from a channel in the browser