function handleStreamMessage(message) {

        Y.log('stream update ' + JSON.stringify(message));

        if (message.type === 'connect') {

            socket.json.send({ type: 'initialize', id: session.id, mac: MAC.macMessage(message.session, session) });
            socketMessage.session = message.session;

        }

        else if (message.type === 'initialize') {

            if (message.status === 'ok') {

                socketMessage.status = message.status;

                // unsubscribeAll is probably too heavy, even if it's a reconnect - just reset the subscription status
                var i, l;
                for (/*var*/i = 0, l = Y.postmile.gpostmile.projects.length; i < l; ++i) {
                    var project = Y.postmile.gpostmile.projects[i];
                    project.subscribed = false; // presume this works (we'd not do anything differently anyways)
                }

                if (Y.postmile && Y.postmile.gpostmile && Y.postmile.gpostmile.project) {
                    subscribe(Y.postmile.gpostmile.project);
                }

            }

        }

        else if (message.type === 'subscribe') {
        }

        else if (message.type === 'disconnect') {

            Y.log('socket message disconnect ' + JSON.stringify(message) + ' ' + JSON.stringify(message));

            // perhaps reconnect, reinitialize again

            if (Y.postmile && Y.postmile.gpostmile && Y.postmile.gpostmile.project) {
                subscribe(Y.postmile.gpostmile.project);
            }

        }

        else if (message.type === 'update') {

            handleStreamUpate(message);

        } else {

            Y.log('socket message else ' + ' ' + JSON.stringify(message));

        }

    }
// handle message coming in on stream socket
handle message coming in on stream socket
handle message coming in on stream socket
function handleStreamMessage(message) {
        Y.log('stream update ' + JSON.stringify(message));
        if (message.type === 'connect') {
            socket.json.send({ type: 'initialize', id: session.id, mac: MAC.macMessage(message.session, session) });
            socketMessage.session = message.session;
        }
        else if (message.type === 'initialize') {
            if (message.status === 'ok') {
                socketMessage.status = message.status;
                var i, l;
                for (i = 0, l = Y.postmile.gpostmile.projects.length; i < l; ++i) {
                    var project = Y.postmile.gpostmile.projects[i];
                    project.subscribed = false; 
                }
                if (Y.postmile && Y.postmile.gpostmile && Y.postmile.gpostmile.project) {
                    subscribe(Y.postmile.gpostmile.project);
                }
            }
        }
        else if (message.type === 'subscribe') {
        }
        else if (message.type === 'disconnect') {
            Y.log('socket message disconnect ' + JSON.stringify(message) + ' ' + JSON.stringify(message));
            if (Y.postmile && Y.postmile.gpostmile && Y.postmile.gpostmile.project) {
                subscribe(Y.postmile.gpostmile.project);
            }
        }
        else if (message.type === 'update') {
            handleStreamUpate(message);
        } else {
            Y.log('socket message else ' + ' ' + JSON.stringify(message));
        }
    }
function handleStreamMessage ( message ) { Y . log ( 'stream update ' + JSON . stringify ( message ) ) ; if ( message . type === 'connect' ) { socket . json . send ( { type : 'initialize' , id : session . id , mac : MAC . macMessage ( message . session , session ) } ) ; socketMessage . session = message . session ; } else if ( message . type === 'initialize' ) { if ( message . status === 'ok' ) { socketMessage . status = message . status ; var i , l ; for ( i = 0 , l = Y . postmile . gpostmile . projects . length ; i < l ; ++ i ) { var project = Y . postmile . gpostmile . projects [ i ] ; project . subscribed = false ; } if ( Y . postmile && Y . postmile . gpostmile && Y . postmile . gpostmile . project ) { subscribe ( Y . postmile . gpostmile . project ) ; } } } else if ( message . type === 'subscribe' ) { } else if ( message . type === 'disconnect' ) { Y . log ( 'socket message disconnect ' + JSON . stringify ( message ) + ' ' + JSON . stringify ( message ) ) ; if ( Y . postmile && Y . postmile . gpostmile && Y . postmile . gpostmile . project ) { subscribe ( Y . postmile . gpostmile . project ) ; } } else if ( message . type === 'update' ) { handleStreamUpate ( message ) ; } else { Y . log ( 'socket message else ' + ' ' + JSON . stringify ( message ) ) ; } }
handle message coming in on stream socket
handle message coming in on stream socket
// unsubscribeAll is probably too heavy, even if it's a reconnect - just reset the subscription status /*var*/ // presume this works (we'd not do anything differently anyways) // perhaps reconnect, reinitialize again