Skip to content

Commit

Permalink
Merge 1e03469 into a402180
Browse files Browse the repository at this point in the history
  • Loading branch information
shriramshankar committed Oct 21, 2016
2 parents a402180 + 1e03469 commit ee4f8e8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ After installing the server, you can run ```redis-cli``` to issue commands to re
- Run ```git push heroku <your branch>:master``` which will push to Heroku and start up a dyno.
- Run ```heroku open``` and view the app running in Heroku
- Run ```heroku run bash``` then run ```mocha``` to execute the test suite

- If you are running the app in more than one dyno, you will need to force the client to communicate with the server only using websockets. To do so, set the config variable SOCKETIO_TRANSPORT_PROTOCOL to websocket or run ```heroku config:set SOCKETIO_TRANSPORT_PROTOCOL=websocket```
If you are running on Heroku and you want to use Google Analytics, store your tracking id in a Heroku config variable called `GOOGLE_ANALYTICS_ID`.

## Using Trace (by RisingStack) for application performance monitoring
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function start() { // eslint-disable-line max-statements

const app = express();
const httpServer = require('http').Server(app);

const io = require('socket.io')(httpServer);
const socketIOSetup = require('./realtime/setupSocketIO');
socketIOSetup.setupNamespace(io);
Expand Down
1 change: 1 addition & 0 deletions view/loadView.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ module.exports = function loadView(app, passport) {
trackingId: viewConfig.trackingId,
user: req.user,
eventThrottle: viewConfig.realtimeEventThrottleMilliseconds,
transportProtocol: viewConfig.socketIOtransportProtocol,
};

const templateVars = Object.assign(
Expand Down
13 changes: 12 additions & 1 deletion view/perspective/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,22 @@ function handleEvent(eventData, eventTypeName) {
function setupSocketIOClient(persBody) {
const namespace = u.getNamespaceString(persBody);

/*
* if the transprotocol is set, initialize the socketio client with
* the transport protocol options. The transProtocol variable is set in
* perspective.pug
*/
const options = {};
const clientProtocol = transProtocol;
if (clientProtocol !== 'undefined') {
options.transports = clientProtocol.replace(/\s*,\s*/g, ',').split(',');
}

/*
* Note: The "io" variable is defined by the "/socket.io.js" script included
* in perspective.pug.
*/
const socket = io(namespace);
const socket = io(namespace, options);
socket.on(eventsQueue.eventType.INTRNL_SUBJ_ADD, (data) => {
handleEvent(data, eventsQueue.eventType.INTRNL_SUBJ_ADD);
});
Expand Down
3 changes: 3 additions & 0 deletions view/perspective/perspective.pug
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ html(lang = 'en')
script(src='/static/socket.io.js')
script.
var realtimeEventThrottleMilliseconds = #{eventThrottle};
script.
var transProtocol = '#{transportProtocol}';

script
if queryParams
| var queryParams = !{queryParams}
Expand Down
4 changes: 4 additions & 0 deletions viewConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ const DEFAULT_THROTTLE_MILLISECS = 4000;
const realtimeEventThrottleMilliseconds =
pe.realtimeEventThrottleMilliseconds || DEFAULT_THROTTLE_MILLISECS;

const socketIOtransportProtocol = pe.SOCKETIO_TRANSPORT_PROTOCOL || 'undefined';
module.exports = {
// Make the Google Analytics trackingId available in /view.
trackingId: pe.GOOGLE_ANALYTICS_ID || 'N/A',

// Make the throttle time available in /view.
realtimeEventThrottleMilliseconds,

// Expose the socketIOtransportProtocol variable in the /view
socketIOtransportProtocol,
};

0 comments on commit ee4f8e8

Please sign in to comment.