Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
narenranjit committed Nov 18, 2016
2 parents 5fb063d + db18fce commit d96ec73
Show file tree
Hide file tree
Showing 33 changed files with 599 additions and 396 deletions.
1 change: 1 addition & 0 deletions dest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
1 change: 0 additions & 1 deletion dist/components/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ $(function () {
});
});

/* jshint multistr:true */
groupSelectionTemplate = window.groupSelectionTemplate = '<form>\
<div class="group-selection-dialog" style="display: none"> \
<div class="panel panel-default form-inline"> \
Expand Down
341 changes: 235 additions & 106 deletions dist/epicenter.js

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions dist/epicenter.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/epicenter.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions documentation/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ If you are comfortable with JavaScript, the epicenter.js library is an easy way

The Epicenter.js library is a set of services (adapters) and managers to help streamline your work with the underlying Epicenter APIs.

Services encapsulate the [Epicenter REST APIs](../rest_apis/). Managers are responsible for configuring, sequencing, and synchronizing services to perform common application tasks. For example, the [Run Manager](./generated/run-manager/) lets you use different [run creation strategies](./strategy/) and returns a pre-configured [Run Service](./generated/run-api-service/) you can then use.
Services encapsulate the [Epicenter REST APIs](../rest_apis/). Managers are responsible for configuring, sequencing, and synchronizing services to perform common application tasks. For example, the [Run Manager](./generated/run-manager/) lets you use different [run creation strategies](./generated/strategies/) and returns a pre-configured [Run Service](./generated/run-api-service/) you can then use.

In most cases you'll work with the managers directly:

* [Authorization Manager](./generated/auth-manager/): The Authorization Manager provides an easy way to manage user authentication (logging in and out) and authorization (keeping track of tokens, sessions, and groups) for projects.
* [Run Manager](./generated/run-manager/): The Run Manager gives you control over run creation depending on run state. You can select run creation [strategies](./strategy/) (rules) for which runs end users of your project work with when they log in to your project.
* [Run Manager](./generated/run-manager/): The Run Manager gives you control over run creation depending on run state. You can select run creation [strategies](./generated/strategies/) (rules) for which runs end users of your project work with when they log in to your project.
* [World Manager](./generated/world-manager/): For building multiplayer games you typically want multiple end users to share the same set of interactions, and work within a common state. Epicenter allows you to create "worlds" to handle such cases. The World Manager provides an easy way to track and access the current world and run for particular end users.
* [Epicenter Channel Manager](./generated/epicenter-channel-manager/) (and the underlying [Channel Manager](./generated/channel-manager/)): Once you've created "[worlds](../glossary/#world)" with the World Manager, you often want end users in each world to be able to communicate: to talk with each other (e.g. a user-to-user chat feature), or to receive updates when something changes in their world (e.g. variables associated with their shared run are updated). The Epicenter Channel Manager provides a publish/subscribe channel using cometd.

Expand Down
32 changes: 32 additions & 0 deletions documentation/run-strategies-template.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Run Manager Strategies
layout: "default"
isPage: true
---

## Run Manager Strategies

The [Run Manager](../run-manager/) gives you control over run creation, depending on run state. You can select run creation stratgies (rules) for which runs end users of your project work with when they log in to your project.

There are several strategies included in epicenter.js:

<? docfiles.forEach(function (doc) { ?><? var moduleName = doc.filename.split('/').pop().split('.')[0].replace('-strategy', '') ?>
* [<?= moduleName ?>](#<?= moduleName ?>)<? }); ?>

You can also [create your own](#create-your-own).

<? docfiles.forEach(function (doc) { ?>
<? var moduleName = doc.filename.split('/').pop().split('.')[0].replace('-strategy', '') ?>
<a name="<?= moduleName ?>"></a>
#### <?= moduleName ?>

<? var moduleDoc = doc.javadoc.shift() ?>
<?= moduleDoc.description ?>
<? }); ?>

<a name="create-your-own"></a>
#### Create your own

You can create your own strategy by passing in a function in the `strategy` parameter to the `F.manager.RunManager()` instantiation call.

Strategy functions must return a boolean value for whether or not to create a new run.
129 changes: 0 additions & 129 deletions documentation/strategy/index.html.md

This file was deleted.

16 changes: 16 additions & 0 deletions grunt/markdox.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ module.exports = function (grunt) {
// Task-specific options go here.
template: 'documentation/template.ejs'
},
strategies: {
options: {
template: 'documentation/run-strategies-template.ejs'
},
files: {
'documentation/generated/strategies/index.html.md': [
'src/managers/run-strategies/always-new-strategy.js',
'src/managers/run-strategies/new-if-persisted-strategy.js',
'src/managers/run-strategies/new-if-missing-strategy.js',
'src/managers/run-strategies/new-if-initialized-strategy.js',
'src/managers/run-strategies/persistent-single-player-strategy.js',
'src/managers/run-strategies/multiplayer-strategy.js',
'src/managers/run-strategies/none-strategy.js',
],
}
},
target: {
files: [
// {
Expand Down
1 change: 1 addition & 0 deletions grunt/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = function (grunt) {
run: true,
growlOnSuccess: false,
reporter: 'Min',
log: true,
options: {
coverage: {
jsonReport: 'coverage'
Expand Down
7 changes: 5 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ var F = {
};

F.load = require('./env-load');
F.load();

if (!global.SKIP_ENV_LOAD) {
F.load();
}

F.util.query = require('./util/query-util');
F.util.run = require('./util/run-util');
Expand Down Expand Up @@ -51,7 +54,7 @@ F.manager.WorldManager = require('./managers/world-manager');

F.manager.strategy['always-new'] = require('./managers/run-strategies/always-new-strategy');
F.manager.strategy['conditional-creation'] = require('./managers/run-strategies/conditional-creation-strategy');
F.manager.strategy.identity = require('./managers/run-strategies/identity-strategy');
F.manager.strategy.identity = require('./managers/run-strategies/none-strategy');
F.manager.strategy['new-if-missing'] = require('./managers/run-strategies/new-if-missing-strategy');
F.manager.strategy['new-if-missing'] = require('./managers/run-strategies/new-if-missing-strategy');
F.manager.strategy['new-if-persisted'] = require('./managers/run-strategies/new-if-persisted-strategy');
Expand Down
26 changes: 7 additions & 19 deletions src/env-load.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
'use strict';

var urlConfigService = require('./service/url-config-service');
var URLConfigService = require('./service/url-config-service');

var envLoad = function (callback) {
var envPromise;
var host;
var urlService = urlConfigService();
var envPath = '/epicenter/v1/config';
if (urlService.isLocalhost()) {
host = 'https://forio.com';
} else {
host = '';
}
var infoUrl = host + envPath;
envPromise = $.ajax({ url: infoUrl, async: false });
envPromise.then(function (res) {
var api = res.api;
$.extend(urlConfigService, api);
}).fail(function (res) {
// Epicenter/webserver not properly configured
// fallback to api.forio.com
$.extend(urlConfigService, { protocol: 'https', host: 'api.forio.com' });
var urlService = new URLConfigService();
var infoUrl = urlService.getAPIPath('config');
var envPromise = $.ajax({ url: infoUrl, async: false });
envPromise = envPromise.then(function (res) {
var overrides = res.api;
URLConfigService.defaults = $.extend(URLConfigService.defaults, overrides);
});
return envPromise.then(callback).fail(callback);
};
Expand Down
10 changes: 4 additions & 6 deletions src/managers/auth-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ function AuthManager(options) {
this.sessionManager = new SessionManager(options);
this.options = this.sessionManager.getMergedOptions();

this.isLocal = this.options.isLocal;
this.authAdapter = new AuthAdapter(this.options);
}

Expand All @@ -59,8 +58,6 @@ var _findUserInGroup = function (members, id) {
return members[j];
}
}


return null;
};

Expand Down Expand Up @@ -129,7 +126,7 @@ AuthManager.prototype = $.extend(AuthManager.prototype, {
var handleSuccess = function (response) {
var token = response.access_token;
var userInfo = decodeToken(token);
var oldGroups = sessionManager.getSession().groups || {};
var oldGroups = sessionManager.getSession(adapterOptions).groups || {};
var userGroupOpts = $.extend(true, {}, adapterOptions, { success: $.noop });
var data = { auth: response, user: userInfo };
var project = adapterOptions.project;
Expand Down Expand Up @@ -269,7 +266,7 @@ AuthManager.prototype = $.extend(AuthManager.prototype, {
getToken: function (options) {
var httpOptions = this.sessionManager.getMergedOptions(options);

var session = this.sessionManager.getSession();
var session = this.sessionManager.getSession(httpOptions);
var $d = $.Deferred();
if (session.auth_token) {
$d.resolve(session.auth_token);
Expand Down Expand Up @@ -342,7 +339,8 @@ AuthManager.prototype = $.extend(AuthManager.prototype, {
* @return {Object} session information
*/
getCurrentUserSessionInfo: function (options) {
return this.sessionManager.getSession(options);
var adapterOptions = this.sessionManager.getMergedOptions({ success: $.noop }, options);
return this.sessionManager.getSession(adapterOptions);
},

/*
Expand Down
Loading

0 comments on commit d96ec73

Please sign in to comment.