examples/realtime/server.js
function sendEvent() {
        var data = {},
            eventName;
        if (++i < c) {
            if (channel.page < channel.numPages) {
                data.pages = [channel.page++];
                eventName = 'pageavailable.svg';
            } else {
                eventName = 'finished.svg';
                data = '';
            }
            response.write('id: ' + i + '\n');
            response.write('event: ' + eventName + '\n');
            response.write('data: ' + (data ? JSON.stringify(data) : '') + '\n\n');
            timeoutId = setTimeout(sendEvent, (Math.random() * 1000 + 50));
        } else {
            response.end();
        }
    }
function sendEvent() {
        var data = {},
            eventName;
        if (++i < c) {
            if (channel.page < channel.numPages) {
                data.pages = [channel.page++];
                eventName = 'pageavailable.svg';
            } else {
                eventName = 'finished.svg';
                data = '';
            }
            response.write('id: ' + i + '\n');
            response.write('event: ' + eventName + '\n');
            response.write('data: ' + (data ? JSON.stringify(data) : '') + '\n\n');
            timeoutId = setTimeout(sendEvent, (Math.random() * 1000 + 50));
        } else {
            response.end();
        }
    }
function sendEvent ( ) { var data = { } , eventName ; if ( ++ i < c ) { if ( channel . page < channel . numPages ) { data . pages = [ channel . page ++ ] ; eventName = 'pageavailable.svg' ; } else { eventName = 'finished.svg' ; data = '' ; } response . write ( 'id: ' + i + '\n' ) ; response . write ( 'event: ' + eventName + '\n' ) ; response . write ( 'data: ' + ( data ? JSON . stringify ( data ) : '' ) + '\n\n' ) ; timeoutId = setTimeout ( sendEvent , ( Math . random ( ) * 1000 + 50 ) ) ; } else { response . end ( ) ; } }
send 100 events before forcing a reconnect
send 100 events before forcing a reconnect