function listenForTweets(url, cb) {

	var ws = new WebSocket(url);

	ws.onopen = function() {
		console.log('Socket Opened');
	};

	// Restart the connection if it closes
	ws.onclose = function() { 
		console.log("Socket Closed... Re-starting");
		listenForTweets(url, cb);
	};

	// Message received...
	ws.onmessage = function(message) {
		var data = JSON.parse(message.data);

		// Make sure it isn't a "nodata" message
		if (typeof(data.latitude) !== 'undefined') {
			// Push data to callback
			cb(data);
		}
	}
}
// Pushes new messages to the view model "addTweet" function
Pushes new messages to the view model "addTweet" function
Pushes new messages to the view model " addTweet " function
function listenForTweets(url, cb) {
	var ws = new WebSocket(url);
	ws.onopen = function() {
		console.log('Socket Opened');
	};
	ws.onclose = function() { 
		console.log("Socket Closed... Re-starting");
		listenForTweets(url, cb);
	};
	ws.onmessage = function(message) {
		var data = JSON.parse(message.data);
		if (typeof(data.latitude) !== 'undefined') {
			cb(data);
		}
	}
}
function listenForTweets ( url , cb ) { var ws = new WebSocket ( url ) ; ws . onopen = function ( ) { console . log ( 'Socket Opened' ) ; } ; ws . onclose = function ( ) { console . log ( "Socket Closed... Re-starting" ) ; listenForTweets ( url , cb ) ; } ; ws . onmessage = function ( message ) { var data = JSON . parse ( message . data ) ; if ( typeof ( data . latitude ) !== 'undefined' ) { cb ( data ) ; } } }
Pushes new messages to the view model "addTweet" function
Pushes new messages to the view model " addTweet " function
// Restart the connection if it closes // Message received... // Make sure it isn't a "nodata" message // Push data to callback