diff --git a/dist/smartsocket.classes.smartsocket.d.ts b/dist/smartsocket.classes.smartsocket.d.ts
index 932de9f..2b10472 100644
--- a/dist/smartsocket.classes.smartsocket.d.ts
+++ b/dist/smartsocket.classes.smartsocket.d.ts
@@ -1,20 +1,18 @@
///
import { Objectmap } from "lik";
-import { SocketRole } from "./smartsocket.classes.socketrole";
+import { SocketConnection } from "./smartsocket.classes.socketconnection";
export interface ISmartsocketConstructorOptions {
port: number;
}
export declare class Smartsocket {
options: ISmartsocketConstructorOptions;
io: SocketIO.Server;
- openSockets: Objectmap;
- registeredFunctions: Objectmap;
+ openSockets: Objectmap;
constructor(optionsArg: ISmartsocketConstructorOptions);
/**
* the standard handler for new socket connections
*/
private _handleSocket(socketArg);
- registerFunction(socketRoleArg: SocketRole): void;
/**
* starts listening to incling sockets:
*/
diff --git a/dist/smartsocket.classes.smartsocket.js b/dist/smartsocket.classes.smartsocket.js
index 68ae306..7808b02 100644
--- a/dist/smartsocket.classes.smartsocket.js
+++ b/dist/smartsocket.classes.smartsocket.js
@@ -1,6 +1,5 @@
"use strict";
const plugins = require("./smartsocket.plugins");
-const helpers = require("./smartsocket.helpers");
// classes
const lik_1 = require("lik");
const smartsocket_classes_socketconnection_1 = require("./smartsocket.classes.socketconnection");
@@ -8,7 +7,6 @@ const smartsocket_classes_socketconnection_1 = require("./smartsocket.classes.so
class Smartsocket {
constructor(optionsArg) {
this.openSockets = new lik_1.Objectmap();
- this.registeredFunctions = new lik_1.Objectmap();
/**
* starts listening to incling sockets:
*/
@@ -39,13 +37,10 @@ class Smartsocket {
});
plugins.beautylog.log("Socket connected. Trying to authenticate...");
this.openSockets.add(socketConnection);
- helpers.authenticateSocket(socketConnection)
- .then();
- }
- registerFunction(socketRoleArg) {
- this.registeredFunctions.add(socketRoleArg);
+ socketConnection.authenticate()
+ .then(socketConnection.listenToFunctionRequests);
}
;
}
exports.Smartsocket = Smartsocket;
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJ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ztJQUVEOztPQUVHO0lBQ0ssYUFBYSxDQUFDLFNBQVM7UUFDM0IsSUFBSSxnQkFBZ0IsR0FBc0IsSUFBSSx1REFBZ0IsQ0FBQztZQUMzRCxhQUFhLEVBQUMsS0FBSztZQUNuQixNQUFNLEVBQUMsU0FBUztTQUNuQixDQUFDLENBQUM7UUFDSCxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyw2Q0FBNkMsQ0FBQyxDQUFBO1FBQ3BFLElBQUksQ0FBQyxXQUFXLENBQUMsR0FBRyxDQUFDLGdCQUFnQixDQUFDLENBQUM7UUFDdkMsZ0JBQWdCLENBQUMsWUFBWSxFQUFFO2FBQzFCLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyx3QkFBd0IsQ0FBQyxDQUFDO0lBQ3pELENBQUM7O0FBb0JMLENBQUM7QUF4Q1ksbUJBQVcsY0F3Q3ZCLENBQUEifQ==
\ No newline at end of file
diff --git a/dist/smartsocket.classes.smartsocketclient.d.ts b/dist/smartsocket.classes.smartsocketclient.d.ts
index db290db..878b239 100644
--- a/dist/smartsocket.classes.smartsocketclient.d.ts
+++ b/dist/smartsocket.classes.smartsocketclient.d.ts
@@ -1,3 +1,6 @@
+///
+import * as plugins from "./smartsocket.plugins";
+import { ISocketFunctionRequestObject, ISocketFunctionResponseObject } from "./smartsocket.classes.socketfunction";
/**
* interface for class SmartsocketClient
*/
@@ -7,4 +10,5 @@ export interface ISmartsocketClientOptions {
}
export declare class SmartsocketClient {
constructor();
+ dispatchFunctionRequest(dataArg: ISocketFunctionRequestObject): plugins.q.Promise;
}
diff --git a/dist/smartsocket.classes.smartsocketclient.js b/dist/smartsocket.classes.smartsocketclient.js
index c34b871..67ebea2 100644
--- a/dist/smartsocket.classes.smartsocketclient.js
+++ b/dist/smartsocket.classes.smartsocketclient.js
@@ -1,7 +1,15 @@
"use strict";
+const plugins = require("./smartsocket.plugins");
class SmartsocketClient {
constructor() {
}
+ dispatchFunctionRequest(dataArg) {
+ let done = plugins.q.defer();
+ let responseData;
+ done.resolve(responseData);
+ return done.promise;
+ }
+ ;
}
exports.SmartsocketClient = SmartsocketClient;
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zbWFydHNvY2tldGNsaWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmNsYXNzZXMuc21hcnRzb2NrZXRjbGllbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQVVBO0lBQ0k7SUFFQSxDQUFDO0FBQ0wsQ0FBQztBQUpZLHlCQUFpQixvQkFJN0IsQ0FBQSJ9
\ No newline at end of file
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zbWFydHNvY2tldGNsaWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmNsYXNzZXMuc21hcnRzb2NrZXRjbGllbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHVCQUl6QixDQUFDLENBSitDO0FBaUJoRDtJQUNJO0lBRUEsQ0FBQztJQUNELHVCQUF1QixDQUFDLE9BQW9DO1FBQ3hELElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFpQyxDQUFDO1FBQzVELElBQUksWUFBMEMsQ0FBQztRQUMvQyxJQUFJLENBQUMsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUFDO1FBQzNCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7O0FBQ0wsQ0FBQztBQVZZLHlCQUFpQixvQkFVN0IsQ0FBQSJ9
\ No newline at end of file
diff --git a/dist/smartsocket.classes.socketconnection.d.ts b/dist/smartsocket.classes.socketconnection.d.ts
index e17707b..9b7b522 100644
--- a/dist/smartsocket.classes.socketconnection.d.ts
+++ b/dist/smartsocket.classes.socketconnection.d.ts
@@ -1,14 +1,39 @@
///
+///
+import * as plugins from "./smartsocket.plugins";
+import { SocketRole } from "./smartsocket.classes.socketrole";
+/**
+ * interface for constructor of class SocketConnection
+ */
export interface ISocketConnectionOptions {
alias?: string;
authenticated: boolean;
- role?: string;
+ role?: SocketRole;
socket: SocketIO.Socket;
}
+/**
+ * interface for authentication data
+ */
+export interface ISocketConnectionAuthenticationObject {
+ role: "coreflowContainer";
+ password: "somePassword";
+ alias: "coreflow1";
+}
+/**
+ * class SocketConnection represents a websocket connection
+ */
export declare class SocketConnection {
alias?: string;
authenticated: boolean;
- role?: string;
+ role?: SocketRole;
socket: SocketIO.Socket;
constructor(optionsArg: ISocketConnectionOptions);
+ /**
+ * authenticate the socket
+ */
+ authenticate(): plugins.q.Promise<{}>;
+ /**
+ * listen to function requests
+ */
+ listenToFunctionRequests(): plugins.q.Promise<{}>;
}
diff --git a/dist/smartsocket.classes.socketconnection.js b/dist/smartsocket.classes.socketconnection.js
index 6c02d4b..6d603eb 100644
--- a/dist/smartsocket.classes.socketconnection.js
+++ b/dist/smartsocket.classes.socketconnection.js
@@ -1,5 +1,11 @@
"use strict";
+const plugins = require("./smartsocket.plugins");
+const helpers = require("./smartsocket.helpers");
;
+// export classes
+/**
+ * class SocketConnection represents a websocket connection
+ */
class SocketConnection {
constructor(optionsArg) {
this.alias = optionsArg.alias;
@@ -7,7 +13,58 @@ class SocketConnection {
this.role = optionsArg.role;
this.socket = optionsArg.socket;
}
+ /**
+ * authenticate the socket
+ */
+ authenticate() {
+ let done = plugins.q.defer();
+ this.socket.on("dataAuth", dataArg => {
+ plugins.beautylog.log("received authentication data. now hashing and comparing...");
+ this.socket.removeListener("dataAuth", () => { });
+ if ((true)) {
+ this.alias = dataArg.alias;
+ this.authenticated = true;
+ this.role = helpers.findSocketRoleByString(dataArg.role);
+ this.socket.emit("authenticated");
+ plugins.beautylog.ok(`socket with >>alias ${this.alias} >>role ${this.role} is authenticated!`);
+ done.resolve(this);
+ }
+ else {
+ this.socket.disconnect();
+ done.reject("not authenticated");
+ }
+ ;
+ });
+ this.socket.emit("requestAuth");
+ return done.promise;
+ }
+ ;
+ /**
+ * listen to function requests
+ */
+ listenToFunctionRequests() {
+ let done = plugins.q.defer();
+ if (this.authenticated) {
+ this.socket.on("function", (dataArg) => {
+ let referencedFunction = this.role.allowedFunctions.find((socketFunctionArg) => {
+ return socketFunctionArg.name === dataArg.functionName;
+ });
+ if (referencedFunction !== undefined) {
+ referencedFunction.invoke(dataArg);
+ }
+ else {
+ plugins.beautylog.warn("function not existent or out of access scope");
+ }
+ ;
+ });
+ }
+ else {
+ done.reject("socket needs to be authenticated first");
+ }
+ ;
+ return done.promise;
+ }
}
exports.SocketConnection = SocketConnection;
;
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRjb25uZWN0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRjb25uZWN0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFPQyxDQUFDO0FBRUY7SUFLSSxZQUFZLFVBQW1DO1FBQzNDLElBQUksQ0FBQyxLQUFLLEdBQUcsVUFBVSxDQUFDLEtBQUssQ0FBQztRQUM5QixJQUFJLENBQUMsYUFBYSxHQUFHLFVBQVUsQ0FBQyxhQUFhLENBQUM7UUFDOUMsSUFBSSxDQUFDLElBQUksR0FBRyxVQUFVLENBQUMsSUFBSSxDQUFDO1FBQzVCLElBQUksQ0FBQyxNQUFNLEdBQUcsVUFBVSxDQUFDLE1BQU0sQ0FBQztJQUNwQyxDQUFDO0FBQ0wsQ0FBQztBQV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FDbkIsSUFBSSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsVUFBVSxFQUFFLENBQUMsT0FBb0M7Z0JBQzVELElBQUksa0JBQWtCLEdBQWtCLElBQUksQ0FBQyxJQUFJLENBQUMsZ0JBQWdCLENBQUMsSUFBSSxDQUFDLENBQUMsaUJBQWlCO29CQUN0RixNQUFNLENBQUMsaUJBQWlCLENBQUMsSUFBSSxLQUFLLE9BQU8sQ0FBQyxZQUFZLENBQUE7Z0JBQzFELENBQUMsQ0FBQyxDQUFDO2dCQUNILEVBQUUsQ0FBQSxDQUFDLGtCQUFrQixLQUFLLFNBQVMsQ0FBQyxDQUFBLENBQUM7b0JBQ2pDLGtCQUFrQixDQUFDLE1BQU0sQ0FBQyxPQUFPLENBQUMsQ0FBQztnQkFDdkMsQ0FBQztnQkFBQyxJQUFJLENBQUMsQ0FBQztvQkFDSixPQUFPLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyw4Q0FBOEMsQ0FBQyxDQUFDO2dCQUMzRSxDQUFDO2dCQUFBLENBQUM7WUFDTixDQUFDLENBQUMsQ0FBQTtRQUNOLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLElBQUksQ0FBQyxNQUFNLENBQUMsd0NBQXdDLENBQUMsQ0FBQztRQUMxRCxDQUFDO1FBQUEsQ0FBQztRQUNGLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7QUFDTCxDQUFDO0FBeERZLHdCQUFnQixtQkF3RDVCLENBQUE7QUFBQSxDQUFDIn0=
\ No newline at end of file
diff --git a/dist/smartsocket.classes.socketfunction.d.ts b/dist/smartsocket.classes.socketfunction.d.ts
index c0ad626..1508bf4 100644
--- a/dist/smartsocket.classes.socketfunction.d.ts
+++ b/dist/smartsocket.classes.socketfunction.d.ts
@@ -1,19 +1,36 @@
import { SocketRole } from "./smartsocket.classes.socketrole";
-export interface ISocketFunctionData {
+export interface ISocketFunctionRequestObject {
functionName: string;
- functionData: any;
+ argumentObject: any;
+ shortId: string;
responseTimeout?: number;
}
+export interface ISocketFunctionResponseObject {
+ shortId: string;
+ argumentObject: any;
+}
export interface SocketFunctionOptions {
name: string;
func: any;
roles: SocketRole[];
}
+/**
+ * class SocketFunction respresents a function that can be transparently called using a SocketConnection
+ */
export declare class SocketFunction {
name: string;
func: any;
roles: SocketRole[];
+ /**
+ * the constructor for SocketFunction
+ */
constructor(optionsArg: SocketFunctionOptions);
+ /**
+ * notifies a role about access to this SocketFunction
+ */
private _notifyRole(socketRoleArg);
- functionRequest(dataArg: ISocketFunctionData): void;
+ /**
+ * invokes the function of this SocketFunction
+ */
+ invoke(dataArg: ISocketFunctionRequestObject): void;
}
diff --git a/dist/smartsocket.classes.socketfunction.js b/dist/smartsocket.classes.socketfunction.js
index 882ad0a..ab42167 100644
--- a/dist/smartsocket.classes.socketfunction.js
+++ b/dist/smartsocket.classes.socketfunction.js
@@ -1,7 +1,15 @@
"use strict";
;
;
+;
+// export classes
+/**
+ * class SocketFunction respresents a function that can be transparently called using a SocketConnection
+ */
class SocketFunction {
+ /**
+ * the constructor for SocketFunction
+ */
constructor(optionsArg) {
this.name = optionsArg.name;
this.func = optionsArg.func;
@@ -11,11 +19,18 @@ class SocketFunction {
}
}
;
+ /**
+ * notifies a role about access to this SocketFunction
+ */
_notifyRole(socketRoleArg) {
socketRoleArg.addSocketFunction(this);
}
- functionRequest(dataArg) {
+ /**
+ * invokes the function of this SocketFunction
+ */
+ invoke(dataArg) {
}
+ ;
}
exports.SocketFunction = SocketFunction;
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRmdW5jdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmNsYXNzZXMuc29ja2V0ZnVuY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXB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UFJLENBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQyxJQUFJLENBQUM7UUFDNUIsSUFBSSxDQUFDLEtBQUssR0FBRyxVQUFVLENBQUMsS0FBSyxDQUFDO1FBQzlCLEdBQUcsQ0FBQyxDQUFDLElBQUksYUFBYSxJQUFJLElBQUksQ0FBQyxLQUFLLENBQUMsQ0FBQSxDQUFDO1lBQ2xDLElBQUksQ0FBQyxXQUFXLENBQUMsYUFBYSxDQUFDLENBQUM7UUFDcEMsQ0FBQztJQUNMLENBQUM7O0lBRUQ7O09BRUc7SUFDSyxXQUFXLENBQUMsYUFBd0I7UUFDeEMsYUFBYSxDQUFDLGlCQUFpQixDQUFDLElBQUksQ0FBQyxDQUFDO0lBQzFDLENBQUM7SUFFRDs7T0FFRztJQUNILE1BQU0sQ0FBQyxPQUFvQztJQUUzQyxDQUFDOztBQUVMLENBQUM7QUEvQlksc0JBQWMsaUJBK0IxQixDQUFBIn0=
\ No newline at end of file
diff --git a/dist/smartsocket.classes.socketrequest.d.ts b/dist/smartsocket.classes.socketrequest.d.ts
new file mode 100644
index 0000000..7e037ea
--- /dev/null
+++ b/dist/smartsocket.classes.socketrequest.d.ts
@@ -0,0 +1,18 @@
+import { ISocketFunctionResponseObject } from "./smartsocket.classes.socketfunction";
+import { Objectmap } from "lik";
+export declare type TSocketRequestStatus = "new" | "pending" | "finished";
+export declare type TSocketRequestSide = "requesting" | "responding";
+export interface SocketRequestConstructorOptions {
+ side: TSocketRequestSide;
+ shortid: string;
+}
+export declare let allRequestingSocketRequests: Objectmap;
+export declare let allRespondingSocketRequests: Objectmap;
+export declare class SocketRequest {
+ status: TSocketRequestStatus;
+ side: TSocketRequestSide;
+ shortid: string;
+ constructor(optionsArg: SocketRequestConstructorOptions);
+ respond(dataArg: ISocketFunctionResponseObject): void;
+ private _dispatch();
+}
diff --git a/dist/smartsocket.classes.socketrequest.js b/dist/smartsocket.classes.socketrequest.js
new file mode 100644
index 0000000..193119f
--- /dev/null
+++ b/dist/smartsocket.classes.socketrequest.js
@@ -0,0 +1,30 @@
+"use strict";
+// import classes
+const lik_1 = require("lik");
+;
+//export objects
+exports.allRequestingSocketRequests = new lik_1.Objectmap();
+exports.allRespondingSocketRequests = new lik_1.Objectmap();
+// export classes
+class SocketRequest {
+ constructor(optionsArg) {
+ this.status = "new";
+ this.side = optionsArg.side;
+ this.shortid = optionsArg.shortid;
+ if (this.side === "requesting") {
+ exports.allRequestingSocketRequests.add(this);
+ }
+ else {
+ exports.allRespondingSocketRequests.add(this);
+ }
+ ;
+ }
+ ;
+ respond(dataArg) {
+ }
+ _dispatch() {
+ }
+}
+exports.SocketRequest = SocketRequest;
+;
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRyZXF1ZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRyZXF1ZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFLQSxpQkFBaUI7QUFDakIsc0JBQTBCLEtBQUssQ0FBQyxDQUFBO0FBVS9CLENBQUM7QUFFRixnQkFBZ0I7QUFDTCxtQ0FBMkIsR0FBRyxJQUFJLGVBQVMsRUFBaUIsQ0FBQztBQUM3RCxtQ0FBMkIsR0FBRyxJQUFJLGVBQVMsRUFBaUIsQ0FBQztBQUV4RSxpQkFBaUI7QUFDakI7SUFJSSxZQUFZLFVBQTJDO1FBSHZELFdBQU0sR0FBeUIsS0FBSyxDQUFDO1FBSWpDLElBQUksQ0FBQyxJQUFJLEdBQUcsVUFBVSxDQUFDLElBQUksQ0FBQztRQUM1QixJQUFJLENBQUMsT0FBTyxHQUFHLFVBQVUsQ0FBQyxPQUFPLENBQUM7UUFDbEMsRUFBRSxDQUFBLENBQUMsSUFBSSxDQUFDLElBQUksS0FBSyxZQUFZLENBQUMsQ0FBQSxDQUFDO1lBQzNCLG1DQUEyQixDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUMxQyxDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDSixtQ0FBMkIsQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLENBQUM7UUFDMUMsQ0FBQztRQUFBLENBQUM7SUFDTixDQUFDOztJQUNELE9BQU8sQ0FBQyxPQUFxQztJQUU3QyxDQUFDO0lBQ08sU0FBUztJQUVqQixDQUFDO0FBQ0wsQ0FBQztBQW5CWSxxQkFBYSxnQkFtQnpCLENBQUE7QUFBQSxDQUFDIn0=
\ No newline at end of file
diff --git a/dist/smartsocket.classes.socketrole.d.ts b/dist/smartsocket.classes.socketrole.d.ts
index 4e7c947..b87dbcd 100644
--- a/dist/smartsocket.classes.socketrole.d.ts
+++ b/dist/smartsocket.classes.socketrole.d.ts
@@ -1,4 +1,6 @@
+import { Objectmap } from "lik";
import { SocketFunction } from "./smartsocket.classes.socketfunction";
+export declare let allSocketRoles: Objectmap;
/**
* interface for class SocketRole
*/
@@ -12,7 +14,7 @@ export interface SocketRoleOptions {
export declare class SocketRole {
name: string;
passwordHash: string;
- allowedFunctions: SocketFunction[];
+ allowedFunctions: Objectmap;
constructor(optionsArg: SocketRoleOptions);
addSocketFunction(socketFunctionArg: SocketFunction): void;
}
diff --git a/dist/smartsocket.classes.socketrole.js b/dist/smartsocket.classes.socketrole.js
index dd32d4a..dbdc6e3 100644
--- a/dist/smartsocket.classes.socketrole.js
+++ b/dist/smartsocket.classes.socketrole.js
@@ -1,16 +1,21 @@
"use strict";
+// import classes
+const lik_1 = require("lik");
+exports.allSocketRoles = new lik_1.Objectmap();
/**
* A socketrole defines access to certain routines.
*/
class SocketRole {
constructor(optionsArg) {
+ this.allowedFunctions = new lik_1.Objectmap();
this.name = optionsArg.name;
this.passwordHash = optionsArg.passwordHash;
+ exports.allSocketRoles.add(this);
}
;
addSocketFunction(socketFunctionArg) {
- this.allowedFunctions.push(socketFunctionArg);
+ this.allowedFunctions.add(socketFunctionArg);
}
}
exports.SocketRole = SocketRole;
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRyb2xlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRyb2xlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFjQTs7R0FFRztBQUNIO0lBSUksWUFBWSxVQUE2QjtRQUNyQyxJQUFJLENBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQyxJQUFJLENBQUM7UUFDNUIsSUFBSSxDQUFDLFlBQVksR0FBRyxVQUFVLENBQUMsWUFBWSxDQUFDO0lBQ2hELENBQUM7O0lBQ0QsaUJBQWlCLENBQUMsaUJBQWdDO1FBQzlDLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxJQUFJLENBQUMsaUJBQWlCLENBQUMsQ0FBQztJQUNsRCxDQUFDO0FBQ0wsQ0FBQztBQVhZLGtCQUFVLGFBV3RCLENBQUEifQ==
\ No newline at end of file
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRyb2xlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRyb2xlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxpQkFBaUI7QUFDakIsc0JBQTBCLEtBQUssQ0FBQyxDQUFBO0FBSXJCLHNCQUFjLEdBQUcsSUFBSSxlQUFTLEVBQWMsQ0FBQztBQVd4RDs7R0FFRztBQUNIO0lBSUksWUFBWSxVQUE2QjtRQUR6QyxxQkFBZ0IsR0FBRyxJQUFJLGVBQVMsRUFBa0IsQ0FBQztRQUUvQyxJQUFJLENBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQyxJQUFJLENBQUM7UUFDNUIsSUFBSSxDQUFDLFlBQVksR0FBRyxVQUFVLENBQUMsWUFBWSxDQUFDO1FBQzVDLHNCQUFjLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQzdCLENBQUM7O0lBQ0QsaUJBQWlCLENBQUMsaUJBQWdDO1FBQzlDLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxHQUFHLENBQUMsaUJBQWlCLENBQUMsQ0FBQztJQUNqRCxDQUFDO0FBQ0wsQ0FBQztBQVpZLGtCQUFVLGFBWXRCLENBQUEifQ==
\ No newline at end of file
diff --git a/dist/smartsocket.helpers.d.ts b/dist/smartsocket.helpers.d.ts
index 97d5898..9d6901c 100644
--- a/dist/smartsocket.helpers.d.ts
+++ b/dist/smartsocket.helpers.d.ts
@@ -1,8 +1,2 @@
-///
-import * as plugins from "./smartsocket.plugins";
-import { SocketConnection } from "./smartsocket.classes.socketconnection";
-/**
- * authenticate a socket
- */
-export declare let authenticateSocket: (socketConnectionArg: SocketConnection) => plugins.q.Promise<{}>;
-export declare let listenToReadySocket: (socketConnectionArg: SocketConnection) => plugins.q.Promise<{}>;
+import { SocketRole } from "./smartsocket.classes.socketrole";
+export declare let findSocketRoleByString: (socketRoleNameArg: string) => SocketRole;
diff --git a/dist/smartsocket.helpers.js b/dist/smartsocket.helpers.js
index b730c04..9a5a3c6 100644
--- a/dist/smartsocket.helpers.js
+++ b/dist/smartsocket.helpers.js
@@ -1,33 +1,7 @@
"use strict";
-const plugins = require("./smartsocket.plugins");
-/**
- * authenticate a socket
- */
-exports.authenticateSocket = (socketConnectionArg) => {
- let done = plugins.q.defer();
- socketConnectionArg.socket.on("dataAuth", dataArg => {
- plugins.beautylog.log("received authentication data. now hashing and comparing...");
- socketConnectionArg.socket.removeListener("dataAuth", () => { });
- if ((true)) {
- socketConnectionArg.alias = dataArg.alias;
- socketConnectionArg.authenticated = true;
- socketConnectionArg.role = dataArg.role;
- socketConnectionArg.socket.emit("authenticated");
- plugins.beautylog.ok(`socket with >>alias ${socketConnectionArg.alias} >>role ${socketConnectionArg.role} is authenticated!`);
- done.resolve(socketConnectionArg);
- }
- else {
- socketConnectionArg.socket.disconnect();
- done.reject("not authenticated");
- }
- ;
- });
- socketConnectionArg.socket.emit("requestAuth");
- return done.promise;
+const smartsocket_classes_socketrole_1 = require("./smartsocket.classes.socketrole");
+// SocketRole helpers
+exports.findSocketRoleByString = (socketRoleNameArg) => {
+ return smartsocket_classes_socketrole_1.allSocketRoles.find((socketRoleArg) => { return socketRoleArg.name === socketRoleNameArg; });
};
-exports.listenToReadySocket = (socketConnectionArg) => {
- let done = plugins.q.defer();
- // socketConnectionArg.socket.listen("function", )
- return done.promise;
-};
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHVCQUF1QixDQUFDLENBQUE7QUFRakQ7O0dBRUc7QUFDUSwwQkFBa0IsR0FBRyxDQUFDLG1CQUFxQztJQUNsRSxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLG1CQUFtQixDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsVUFBVSxFQUFFLE9BQU87UUFDN0MsT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsNERBQTRELENBQUMsQ0FBQztRQUNwRixtQkFBbUIsQ0FBQyxNQUFNLENBQUMsY0FBYyxDQUFDLFVBQVUsRUFBRSxRQUFRLENBQUMsQ0FBQyxDQUFD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Q3hCLENBQUMsQ0FBQSJ9
\ No newline at end of file
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQU1BLGlEQUEyQyxrQ0FBa0MsQ0FBQyxDQUFBO0FBRzlFLHFCQUFxQjtBQUNWLDhCQUFzQixHQUFHLENBQUMsaUJBQXlCO0lBQzFELE1BQU0sQ0FBQywrQ0FBYyxDQUFDLElBQUksQ0FBQyxDQUFDLGFBQWEsT0FBTyxNQUFNLENBQUMsYUFBYSxDQUFDLElBQUksS0FBSyxpQkFBaUIsQ0FBQSxDQUFDLENBQUMsQ0FBQyxDQUFBO0FBQ3RHLENBQUMsQ0FBQyJ9
\ No newline at end of file
diff --git a/dist/smartsocket.plugins.d.ts b/dist/smartsocket.plugins.d.ts
index c2cdd28..fe4f395 100644
--- a/dist/smartsocket.plugins.d.ts
+++ b/dist/smartsocket.plugins.d.ts
@@ -2,6 +2,7 @@ import "typings-global";
export import beautylog = require("beautylog");
export import lik = require("lik");
export import q = require("q");
+export import shortid = require("shortid");
export import socketIo = require("socket.io");
export import socketIoClient = require("socket.io-client");
export import taskbuffer = require("taskbuffer");
diff --git a/dist/smartsocket.plugins.js b/dist/smartsocket.plugins.js
index 53e7b41..951bb2f 100644
--- a/dist/smartsocket.plugins.js
+++ b/dist/smartsocket.plugins.js
@@ -3,7 +3,8 @@ require("typings-global");
exports.beautylog = require("beautylog");
exports.lik = require("lik");
exports.q = require("q");
+exports.shortid = require("shortid");
exports.socketIo = require("socket.io");
exports.socketIoClient = require("socket.io-client");
exports.taskbuffer = require("taskbuffer");
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUNWLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsV0FBRyxXQUFZLEtBQUssQ0FBQyxDQUFDO0FBQ3RCLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUNqQixnQkFBUSxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2hDLHNCQUFjLFdBQVcsa0JBQWtCLENBQUMsQ0FBQztBQUM3QyxrQkFBVSxXQUFXLFlBQVksQ0FBQyxDQUFDIn0=
\ No newline at end of file
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUNWLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsV0FBRyxXQUFZLEtBQUssQ0FBQyxDQUFDO0FBQ3RCLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUNqQixlQUFPLFdBQVcsU0FBUyxDQUFDLENBQUM7QUFDN0IsZ0JBQVEsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNoQyxzQkFBYyxXQUFXLGtCQUFrQixDQUFDLENBQUM7QUFDN0Msa0JBQVUsV0FBVyxZQUFZLENBQUMsQ0FBQyJ9
\ No newline at end of file
diff --git a/ts/smartsocket.classes.smartsocketclient.ts b/ts/smartsocket.classes.smartsocketclient.ts
index 2dd2433..afc3c97 100644
--- a/ts/smartsocket.classes.smartsocketclient.ts
+++ b/ts/smartsocket.classes.smartsocketclient.ts
@@ -1,15 +1,28 @@
import * as plugins from "./smartsocket.plugins"
+
+// import interfaces
+import { ISocketFunctionRequestObject, ISocketFunctionResponseObject } from "./smartsocket.classes.socketfunction";
+
+// import classes
+import { SocketFunction } from "./smartsocket.classes.socketfunction";
+
/**
* interface for class SmartsocketClient
*/
export interface ISmartsocketClientOptions {
- port:number;
- url:string;
+ port: number;
+ url: string;
}
export class SmartsocketClient {
- constructor(){
+ constructor() {
}
+ dispatchFunctionRequest(dataArg:ISocketFunctionRequestObject): plugins.q.Promise {
+ let done = plugins.q.defer();
+ let responseData:ISocketFunctionResponseObject;
+ done.resolve(responseData);
+ return done.promise;
+ };
}
\ No newline at end of file
diff --git a/ts/smartsocket.classes.socketconnection.ts b/ts/smartsocket.classes.socketconnection.ts
index 285bfff..8f3c107 100644
--- a/ts/smartsocket.classes.socketconnection.ts
+++ b/ts/smartsocket.classes.socketconnection.ts
@@ -2,9 +2,15 @@ import * as plugins from "./smartsocket.plugins";
import * as helpers from "./smartsocket.helpers";
// import classes
+import { SocketFunction, ISocketFunctionRequestObject } from "./smartsocket.classes.socketfunction";
+import { SocketRequest } from "./smartsocket.classes.socketrequest";
import { SocketRole } from "./smartsocket.classes.socketrole";
-import { SocketFunction, ISocketFunctionData } from "./smartsocket.classes.socketfunction";
+// export interfaces
+
+/**
+ * interface for constructor of class SocketConnection
+ */
export interface ISocketConnectionOptions {
alias?: string;
authenticated: boolean;
@@ -12,6 +18,20 @@ export interface ISocketConnectionOptions {
socket: SocketIO.Socket;
};
+/**
+ * interface for authentication data
+ */
+export interface ISocketConnectionAuthenticationObject {
+ role: "coreflowContainer",
+ password: "somePassword",
+ alias: "coreflow1"
+}
+
+// export classes
+
+/**
+ * class SocketConnection represents a websocket connection
+ */
export class SocketConnection {
alias?: string;
authenticated: boolean;
@@ -53,8 +73,15 @@ export class SocketConnection {
listenToFunctionRequests() {
let done = plugins.q.defer();
if(this.authenticated){
- this.socket.on("function", (dataArg:ISocketFunctionData) => {
- this.role.allowedFunctions
+ this.socket.on("function", (dataArg:ISocketFunctionRequestObject) => {
+ let referencedFunction:SocketFunction = this.role.allowedFunctions.find((socketFunctionArg) => {
+ return socketFunctionArg.name === dataArg.functionName
+ });
+ if(referencedFunction !== undefined){
+ referencedFunction.invoke(dataArg);
+ } else {
+ plugins.beautylog.warn("function not existent or out of access scope");
+ };
})
} else {
done.reject("socket needs to be authenticated first");
diff --git a/ts/smartsocket.classes.socketfunction.ts b/ts/smartsocket.classes.socketfunction.ts
index 1b6215e..6fbfe90 100644
--- a/ts/smartsocket.classes.socketfunction.ts
+++ b/ts/smartsocket.classes.socketfunction.ts
@@ -4,18 +4,31 @@ import * as plugins from "./smartsocket.plugins";
import { Stringmap } from "lik";
import { SocketRole } from "./smartsocket.classes.socketrole";
-export interface ISocketFunctionData {
+// export interfaces
+
+export interface ISocketFunctionRequestObject {
functionName:string,
- functionData:any,
+ argumentObject:any,
+ shortId:string,
responseTimeout?:number
};
+export interface ISocketFunctionResponseObject {
+ shortId:string;
+ argumentObject:any;
+};
+
export interface SocketFunctionOptions {
name: string;
func: any;
roles: SocketRole[]; // all roles that are allowed to execute a SocketFunction
};
+// export classes
+
+/**
+ * class SocketFunction respresents a function that can be transparently called using a SocketConnection
+ */
export class SocketFunction {
name: string;
func: any;
@@ -41,9 +54,9 @@ export class SocketFunction {
}
/**
- * handles a function request to this SocketFunction
+ * invokes the function of this SocketFunction
*/
- functionRequest(dataArg:ISocketFunctionData){
+ invoke(dataArg:ISocketFunctionRequestObject){
};
diff --git a/ts/smartsocket.classes.socketrequest.ts b/ts/smartsocket.classes.socketrequest.ts
new file mode 100644
index 0000000..a0a1eaa
--- /dev/null
+++ b/ts/smartsocket.classes.socketrequest.ts
@@ -0,0 +1,43 @@
+import * as plugins from "./smartsocket.plugins";
+
+// import interfaces
+import { ISocketFunctionRequestObject, ISocketFunctionResponseObject } from "./smartsocket.classes.socketfunction";
+
+// import classes
+import { Objectmap } from "lik";
+import { SocketFunction } from "./smartsocket.classes.socketfunction";
+
+// export interfaces
+export type TSocketRequestStatus = "new" | "pending" | "finished";
+export type TSocketRequestSide = "requesting" | "responding";
+
+export interface SocketRequestConstructorOptions {
+ side: TSocketRequestSide;
+ shortid: string;
+};
+
+//export objects
+export let allRequestingSocketRequests = new Objectmap();
+export let allRespondingSocketRequests = new Objectmap();
+
+// export classes
+export class SocketRequest {
+ status: TSocketRequestStatus = "new";
+ side: TSocketRequestSide;
+ shortid: string;
+ constructor(optionsArg: SocketRequestConstructorOptions) {
+ this.side = optionsArg.side;
+ this.shortid = optionsArg.shortid;
+ if(this.side === "requesting"){
+ allRequestingSocketRequests.add(this);
+ } else {
+ allRespondingSocketRequests.add(this);
+ };
+ };
+ respond(dataArg:ISocketFunctionResponseObject){
+
+ }
+ private _dispatch(){ // note: dispatch is private as it will be fired from the constructor
+
+ }
+};
diff --git a/ts/smartsocket.plugins.ts b/ts/smartsocket.plugins.ts
index 9a564b4..a8e3b07 100644
--- a/ts/smartsocket.plugins.ts
+++ b/ts/smartsocket.plugins.ts
@@ -2,6 +2,7 @@ import "typings-global";
export import beautylog = require("beautylog");
export import lik = require("lik");
export import q = require("q");
+export import shortid = require("shortid");
export import socketIo = require("socket.io");
export import socketIoClient = require("socket.io-client");
export import taskbuffer = require("taskbuffer");
\ No newline at end of file