Created
July 12, 2012 20:19
-
-
Save lxbarth/3100686 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/app.js b/app.js | |
| index ea3e819..f7a2194 100644 | |
| --- a/app.js | |
| +++ b/app.js | |
| @@ -52,6 +52,9 @@ io.set('authorization', function (data, accept) { | |
| } else { | |
| // save the session data and accept the connection | |
| data.session = session; | |
| + // Pass on session store to allow socket.io connections | |
| + // store to session. See data/socket.js. | |
| + data.session_store = app.session_store; | |
| accept(null, true); | |
| } | |
| }) | |
| diff --git a/data/socket.js b/data/socket.js | |
| index c25d0c2..ae74e1e 100644 | |
| --- a/data/socket.js | |
| +++ b/data/socket.js | |
| @@ -123,11 +123,20 @@ var commands = { | |
| if (opt.schemaid && this.dataset._info.schema[opt.schemaid]) { | |
| this.state.preview.schemaid = opt.schemaid; | |
| this.dataset.setPreviewVersion('schema', opt.schemaid); | |
| + | |
| + // OUCH 1 | |
| + // Previews are stuck onto sessions, but somehow socket.io doe | |
| + // not wind up calling response.end() which normally takes care | |
| + // of storing the session. Async nature of request handling forces | |
| + // us to pass down pointer to session store all the way to here. | |
| + this.session_store.set(this.sessionID, this.session); | |
| } | |
| if (opt.dataid && this.dataset._info.data[opt.dataid]) { | |
| this.state.preview.dataid = opt.dataid; | |
| this.dataset.setPreviewVersion('data', opt.dataid); | |
| + // OUCH 2 | |
| + this.session_store.set(this.sessionID, this.session); | |
| } | |
| if (this.validationJob.status === 'successful') { | |
| @@ -151,6 +160,8 @@ var commands = { | |
| this.state.preview = {}; | |
| this.state.status = 'active'; | |
| this.dataset.resetPreview(); | |
| + // OUCH 3 | |
| + this.session_store.set(this.sessionID, this.session); | |
| }), | |
| setActiveVersion: wrapWithDataset(function(opt) { | |
| @@ -196,6 +207,9 @@ function init() { | |
| client.emit('updateState', data.DatasetCollection); | |
| context.session = client.handshake.session; | |
| + // Also pass on session store, see setPreviewVersion(). | |
| + context.session_store = client.handshake.session_store; | |
| + context.sessionID = client.handshake.sessionID; | |
| _(commands).each(function(cmd, name) { | |
| client.on(name, _(cmd).bind(context)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment