Skip to content

Commit

Permalink
use string based RPC for data events for better perf
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed Feb 18, 2017
1 parent 12bda39 commit 9f9da68
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ app.on('ready', () => installDevExtensions(isDev).then(() => {
});

session.on('data', data => {
rpc.emit('session data', {uid, data});
rpc.emit('session data', uid + data);
});

session.on('exit', () => {
Expand Down
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ rpc.on('session add', data => {
// debouncing, to reduce allocation and iterations
let req;
let objects = {};
rpc.on('session data', ({uid, data}) => {
rpc.on('session data', d => {
// the uid is a uuid v4 so it's 36 chars long
const uid = d.slice(0, 36);
const data = d.slice(36);
if (objects[uid] === undefined) {
objects[uid] = data;
} else {
Expand Down

0 comments on commit 9f9da68

Please sign in to comment.