Skip to content

Commit

Permalink
Merge pull request #1 from mage/0.2.0
Browse files Browse the repository at this point in the history
v0.2.0
  • Loading branch information
Ron Korving committed Dec 11, 2014
2 parents 28f078a + 97054b8 commit 9d03f94
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 52 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# mage.js changelog

## v0.2.0
* Updated dependency mage-http-server.js from v0.1.0 to v0.1.1
* Updated dependency mage-loader.js from v0.1.3 to v0.2.0
* Updated dependency mage-message-server.js from v0.1.0 to v0.2.0
* Using a new config format.

## v0.1.0
* Initial Release
8 changes: 4 additions & 4 deletions component.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "mage",
"repo": "mage/mage.js",
"version": "0.1.0",
"version": "0.2.0",
"description": "MAGE's javscript client",
"dependencies": {
"component/emitter": "1.1.3",
"component/inherit": "0.0.3",
"mage/event-manager.js": "0.1.1",
"mage/http-server.js": "0.1.0",
"mage/loader.js": "0.1.2",
"mage/message-server.js": "0.1.0"
"mage/http-server.js": "0.1.1",
"mage/loader.js": "0.2.0",
"mage/message-server.js": "0.2.0"
},
"scripts": [
"index.js"
Expand Down
66 changes: 18 additions & 48 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,58 +104,39 @@ Mage.prototype.configure = function (config) {
throw new Error('Mage requires a config to be instantiated.');
}

var that = this;

this.config = config;

this.appName = config.appName;
this.appConfig = config.appConfig || {};
this.appVersion = config.appVersion;
this.appVariants = config.appVariants;
this.clientHostBaseUrl = config.clientHostBaseUrl;
this.savvyBaseUrl = config.savvyBaseUrl;
this.language = loader.clientConfig.language;
this.density = loader.clientConfig.density;

// set up httpServer
// set up server connections

var httpWithCredentials = config.cors && config.cors.credentials ? true : false;

this.httpServer.setupCommandSystem({
url: config.clientHostBaseUrl + '/' + config.appName,
httpOptions: {
timeout: config.timeout || 15000,
withCredentials: httpWithCredentials,
noCache: true
}
});
this.clientHostBaseUrl = config.baseUrl;
this.savvyBaseUrl = config.server.savvy.url; // TODO: what about server.savvy.cors?

// set up msgServer
// When a session key is available, start the message stream.
// If the key changes, make the event system aware (by simply calling setupMessageStream again)
this.httpServer.setupCommandSystem(config.server.commandCenter);

if (!config.msgStreamUrl) {
return;
}
if (this.msgServer.setupMessageStream(config.server.msgStream)) {
var that = this;

var msgStreamConfig = {
url: config.msgStreamUrl,
httpOptions: {
withCredentials: httpWithCredentials,
noCache: true
}
};
// When a session key is available, start the message stream.
// If the key changes, make the event system aware (by simply calling setupMessageStream again)

this.once('created.session', function () {
that.eventManager.on('session.set', function (path, session) {
that.msgServer.setupMessageStream(msgStreamConfig, session.key);
that.msgServer.start();
});
this.once('created.session', function () {
that.eventManager.on('session.set', function (path, session) {
that.msgServer.setSessionKey(session.key);
that.msgServer.start();
});

that.eventManager.on('session.unset', function () {
that.msgServer.abort();
that.eventManager.on('session.unset', function () {
that.msgServer.abort();
});
});
});
}
};


Expand Down Expand Up @@ -307,18 +288,7 @@ Mage.prototype.useModules = function () {
throw new TypeError('useModules: the first argument must be require.');
}

var userCommands = this.config.userCommands;
var commands = {};

for (var name in userCommands) {
var userCommand = userCommands[name];

if (!commands[userCommand.gameModule]) {
commands[userCommand.gameModule] = []
}

commands[userCommand.gameModule].push({ name: userCommand.cmdName, params: userCommand.mod.params });
}
var commands = this.config.server.commandCenter.commands;

for (var i = 1; i < arguments.length; i += 1) {
var name = arguments[i];
Expand Down

0 comments on commit 9d03f94

Please sign in to comment.