function makePeerHeartbeater(peer) {
    console.log('Heartbeat Started.');
    var timeoutId = 0;

    function heartbeat() {
        timeoutId = setTimeout(heartbeat, 20000);
        if (peer.socket._wsOpen()) {
            peer.socket.send({
                type: 'HEARTBEAT'
            });
        }
    }
    // Start
    heartbeat();
    // return
    return {
        start: function() {
            if (timeoutId === 0) {
                heartbeat();
            }
        },
        stop: function() {
            clearTimeout(timeoutId);
            timeoutId = 0;
        }
    };
}
/**
 * Make a peer heart beat connection to keep
 * the server alive when connected to our
 * heroku applications.
 *
 * @param peer - Current peer object.
 * @return void
 */
Make a peer heart beat connection to keep
the server alive when connected to our
heroku applications.

@param peer - Current peer object.
@return void
Make a peer heart beat connection to keep the server alive when connected to our heroku applications . @param peer - Current peer object . @return void
function makePeerHeartbeater(peer) {
    console.log('Heartbeat Started.');
    var timeoutId = 0;
    function heartbeat() {
        timeoutId = setTimeout(heartbeat, 20000);
        if (peer.socket._wsOpen()) {
            peer.socket.send({
                type: 'HEARTBEAT'
            });
        }
    }
    heartbeat();
    return {
        start: function() {
            if (timeoutId === 0) {
                heartbeat();
            }
        },
        stop: function() {
            clearTimeout(timeoutId);
            timeoutId = 0;
        }
    };
}
function makePeerHeartbeater ( peer ) { console . log ( 'Heartbeat Started.' ) ; var timeoutId = 0 ; function heartbeat ( ) { timeoutId = setTimeout ( heartbeat , 20000 ) ; if ( peer . socket . _wsOpen ( ) ) { peer . socket . send ( { type : 'HEARTBEAT' } ) ; } } heartbeat ( ) ; return { start : function ( ) { if ( timeoutId === 0 ) { heartbeat ( ) ; } } , stop : function ( ) { clearTimeout ( timeoutId ) ; timeoutId = 0 ; } } ; }
Make a peer heart beat connection to keep
 the server alive when connected to our
 heroku applications.
Make a peer heart beat connection to keep the server alive when connected to our heroku applications .
// Start // return