Skip to content

Commit

Permalink
#205 socket io set query string; transport type from gme config.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zsolt Lattmann committed Mar 11, 2015
1 parent d29ce69 commit 0d71659
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 59 deletions.
14 changes: 4 additions & 10 deletions src/common/storage/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,11 @@ define([ "util/assert", "util/guid" ], function (ASSERT, GUID) {
};

var IOReady = function () {
var socketIoOpts = JSON.parse(JSON.stringify(gmeConfig.socketIO)); // Copy this values.
socketIoOpts.query = "webGMESessionId=" + options.webGMESessionId; //FIXME this will be undefined in some cases
var socketIoOpts = JSON.parse(JSON.stringify(gmeConfig.socketIO)); // Copy these values.
if (options.webGMESessionId) {
socketIoOpts.query = 'webGMESessionId=' + options.webGMESessionId; //FIXME this will be undefined in some cases
}
socket = IO.connect(_hostAddress, socketIoOpts);
//socket = IO.connect(_hostAddress,{
// 'connect timeout': 10,
// 'reconnection delay': 1,
// 'force new connection': true,
// 'reconnect': false, // FIXME: should we set it to true?
// 'query':"webGMESessionId="+options.webGMESessionId, //this option is only used when some user initiated server function connects to the webgme server
// 'transports': ['websocket']
//});

socket.on('connect', function () {
socketConnected = true;
Expand Down
18 changes: 0 additions & 18 deletions src/common/storage/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,6 @@ define(["mongodb", "util/assert", "util/canon"], function (MONGODB, ASSERT, CANO
function openDatabase(callback) {
//ASSERT(mongo === null && typeof callback === "function");


/*mongo = new MONGODB.Db(options.database, new MONGODB.Server(options.host, options.port), {
'w': 1,
'auto_reconnect': true,
'poolSize': 20,
socketOptions: {keepAlive: 1}
});
mongo.open(function (err) {
if (err) {
mongo.close();
mongo = null;
callback(err);
} else {
callback(null);
}
});*/

MONGODB.MongoClient.connect(gmeConfig.mongo.uri, gmeConfig.mongo.options, function (err, db) {
if (!err && db) {
mongo = db;
Expand Down
32 changes: 4 additions & 28 deletions src/common/storage/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,40 +166,16 @@ define([ "util/assert","util/guid","util/url","socket.io","worker/serverworkerma
}

function open(){
//TODO: this socketIO should probably have the same options as the client.
_socket = IO.listen(options.combined ? options.combined : gmeConfig.server.port,{
'transports': [
'websocket'
]
_socket = IO.listen(options.combined ? options.combined : gmeConfig.server.port, {
'transports': gmeConfig.socketIO.transports
});

_socket.use(function(socket, next) {
var handshakeData = socket.handshake;
//either the html header contains some webgme signed cookie with the sessionID
// or the data has a webGMESession member which should also contain the sessionID - currently the same as the cookie
if (options.session === true){
var sessionID;
/*if(data.webGMESessionId === undefined){
if(data.query && data.query.webGMESessionId && data.query.webGMESessionId !== 'undefined'){
sessionID = data.query.webGMESessionId;
}
}
if(sessionID === null || sessionID === undefined){
if(data.headers.cookie){
var cookie = URL.parseCookie(data.headers.cookie);
if(cookie[options.cookieID] !== undefined || cookie[options.cookieID] !== null){
sessionID = require('connect').utils.parseSignedCookie(cookie[options.cookieID],options.secret);
data.query = data.query || {};
data.query.webGMESessionId = sessionID;
data.webGMESessionId = sessionID;
}
} else {
console.log('DEBUG COOKIE INFO', JSON.stringify(data.headers));
console.log('DEBUG HANDSHAKE INFO', JSON.stringify(data.query));
return accept(null,false);
}
}*/
sessionID = getSessionID(handshakeData);
if (gmeConfig.authentication.enable === true){
var sessionID = getSessionID(handshakeData);
options.sessioncheck(sessionID,function(err,isOk){
if(!err && isOk === true){
return next();
Expand Down
4 changes: 1 addition & 3 deletions src/server/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ define(['logManager',
//creating the proper storage for the standalone server
__storageOptions = {
combined: __httpServer,
logger: LogManager.create('StandAloneWebGMEServer-socket.io'),
session: false
logger: LogManager.create('StandAloneWebGMEServer-socket.io')
};
if (true === gmeConfig.authentication.enable) {
//__storageOptions.auth = {
Expand All @@ -102,7 +101,6 @@ define(['logManager',
// database: gmeConfig.mongodatabase,
// guest: gmeConfig.guest
//};
__storageOptions.session = true; // FIXME: How does this differ from gmeConfig.authentication.enable?
__storageOptions.sessioncheck = __sessionStore.check;
__storageOptions.authorization = globalAuthorization;
__storageOptions.auth_deleteProject = __gmeAuth.deleteProject;
Expand Down

0 comments on commit 0d71659

Please sign in to comment.