Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: implement sessions #289

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion jstp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ Object.assign(jstp,
jstp.RemoteProxy = require('./lib/remote-proxy');
jstp.Connection = require('./lib/connection');
jstp.Server = require('./lib/server');
jstp.Session = require('./lib/session');

jstp.net = require('./lib/net');
jstp.tls = require('./lib/tls');
jstp.ws = require('./lib/ws');
jstp.wss = require('./lib/wss');

jstp.SimpleAuthPolicy = require('./lib/simple-auth-policy');
jstp.SimpleConnectPolicy = require('./lib/simple-connect-policy');
jstp.SimpleSessionStorageProvider = require(
'./lib/simple-session-storage-provider'
);
11 changes: 10 additions & 1 deletion lib/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ const errors = require('./errors');
// version - application version of 'name' application (optional).
// If a version is not provided either here or in `name`,
// '1.0.0' will be used
// sessionStorageProvider - provider for session storage (optional).
// If provided, it will be used to store sessions
// independently of other applications
//
class Application {
constructor(name, api, eventHandlers = {}, version) {
constructor(name, api, eventHandlers = {}, version, sessionStorageProvider) {
if (sessionStorageProvider === undefined && typeof version === 'object') {
sessionStorageProvider = version;
version = null;
}
[this.name, this.version] = common.rsplit(name, '@');
const providedVersion = this.version || version;
if (providedVersion && !semver.valid(providedVersion)) {
Expand All @@ -30,6 +38,7 @@ class Application {
this.version = providedVersion || '1.0.0';
this.api = api;
this.eventHandlers = eventHandlers;
this.sessionsStorage = sessionStorageProvider;
}

// Call application method
Expand Down
Loading