update tests:
starting with updating tests to use both server and client side to mimic operation
This commit is contained in:
parent
3afede95fc
commit
ab2196fd5f
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -4,4 +4,5 @@ function __export(m) {
|
||||
}
|
||||
__export(require("./smartsocket.classes.smartsocket"));
|
||||
__export(require("./smartsocket.classes.smartsocketclient"));
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsaUJBQWMsbUNBQW1DLENBQUMsRUFBQTtBQUNsRCxpQkFBYyx5Q0FBeUMsQ0FBQyxFQUFBIn0=
|
||||
// need something more exposed? Create an issue on GitLab!
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsaUJBQWMsbUNBQW1DLENBQUMsRUFBQTtBQUNsRCxpQkFBYyx5Q0FBeUMsQ0FBQyxFQUFBO0FBRXhELDBEQUEwRCJ9
|
3
dist/smartsocket.classes.smartsocket.d.ts
vendored
3
dist/smartsocket.classes.smartsocket.d.ts
vendored
@ -12,10 +12,11 @@ export declare class Smartsocket {
|
||||
/**
|
||||
* the standard handler for new socket connections
|
||||
*/
|
||||
private _handleSocket(socketArg);
|
||||
private _handleSocketConnection(socketArg);
|
||||
/**
|
||||
* starts listening to incling sockets:
|
||||
*/
|
||||
startServer: () => void;
|
||||
closeServer: () => void;
|
||||
clientCall(): void;
|
||||
}
|
||||
|
10
dist/smartsocket.classes.smartsocket.js
vendored
10
dist/smartsocket.classes.smartsocket.js
vendored
@ -13,7 +13,7 @@ class Smartsocket {
|
||||
this.startServer = () => {
|
||||
this.io = plugins.socketIo(this.options.port);
|
||||
this.io.on('connection', (socketArg) => {
|
||||
this._handleSocket(socketArg);
|
||||
this._handleSocketConnection(socketArg);
|
||||
});
|
||||
};
|
||||
this.closeServer = () => {
|
||||
@ -30,7 +30,7 @@ class Smartsocket {
|
||||
/**
|
||||
* the standard handler for new socket connections
|
||||
*/
|
||||
_handleSocket(socketArg) {
|
||||
_handleSocketConnection(socketArg) {
|
||||
let socketConnection = new smartsocket_classes_socketconnection_1.SocketConnection({
|
||||
authenticated: false,
|
||||
socket: socketArg
|
||||
@ -41,6 +41,10 @@ class Smartsocket {
|
||||
.then(socketConnection.listenToFunctionRequests);
|
||||
}
|
||||
;
|
||||
// communication
|
||||
clientCall() {
|
||||
// TODO: target specific client and initiate response
|
||||
}
|
||||
}
|
||||
exports.Smartsocket = Smartsocket;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zbWFydHNvY2tldC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmNsYXNzZXMuc21hcnRzb2NrZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHVCQUF1QixDQUFDLENBQUE7QUFHakQsVUFBVTtBQUNWLHNCQUEwQixLQUFLLENBQUMsQ0FBQTtBQUdoQyx1REFBaUMsd0NBQXdDLENBQUMsQ0FBQTtBQUt6RSxDQUFDO0FBRUY7SUFJSSxZQUFZLFVBQTBDO1FBRHRELGdCQUFXLEdBQUcsSUFBSSxlQUFTLEVBQW9CLENBQUM7UUFtQmhEOztXQUVHO1FBRUgsZ0JBQVcsR0FBRztZQUNWLElBQUksQ0FBQyxFQUFFLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO1lBQ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JBQ2pGLGVBQWUsQ0FBQyxNQUFNLENBQUMsVUFBVSxFQUFFLENBQUM7WUFDeEMsQ0FBQyxDQUFDLENBQUM7WUFDSCxJQUFJLENBQUMsV0FBVyxDQUFDLElBQUksRUFBRSxDQUFDO1lBQ3hCLElBQUksQ0FBQyxFQUFFLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDcEIsQ0FBQyxDQUFDO1FBbENFLElBQUksQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFDO0lBQzlCLENBQUM7O0lBRUQ7O09BRUc7SUFDSyx1QkFBdUIsQ0FBQyxTQUFTO1FBQ3JDLElBQUksZ0JBQWdCLEdBQXNCLElBQUksdURBQWdCLENBQUM7WUFDM0QsYUFBYSxFQUFDLEtBQUs7WUFDbkIsTUFBTSxFQUFDLFNBQVM7U0FDbkIsQ0FBQyxDQUFDO1FBQ0gsT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsNkNBQTZDLENBQUMsQ0FBQTtRQUNwRSxJQUFJLENBQUMsV0FBVyxDQUFDLEdBQUcsQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDO1FBQ3ZDLGdCQUFnQixDQUFDLFlBQVksRUFBRTthQUMxQixJQUFJLENBQUMsZ0JBQWdCLENBQUMsd0JBQXdCLENBQUMsQ0FBQztJQUN6RCxDQUFDOztJQXFCRCxnQkFBZ0I7SUFDaEIsVUFBVTtRQUNOLDZEQUE2RDtJQUNqRSxDQUFDO0FBQ0wsQ0FBQztBQTdDWSxtQkFBVyxjQTZDdkIsQ0FBQSJ9
|
10
dist/smartsocket.classes.smartsocketclient.d.ts
vendored
10
dist/smartsocket.classes.smartsocketclient.d.ts
vendored
@ -1,3 +1,5 @@
|
||||
/// <reference types="q" />
|
||||
import * as plugins from "./smartsocket.plugins";
|
||||
import { ISocketFunctionCall } from "./smartsocket.classes.socketfunction";
|
||||
import { SocketConnection } from "./smartsocket.classes.socketconnection";
|
||||
/**
|
||||
@ -6,9 +8,15 @@ import { SocketConnection } from "./smartsocket.classes.socketconnection";
|
||||
export interface ISmartsocketClientOptions {
|
||||
port: number;
|
||||
url: string;
|
||||
alias?: string;
|
||||
password: string;
|
||||
}
|
||||
export declare class SmartsocketClient {
|
||||
socketConnection: SocketConnection;
|
||||
serverUrl: string;
|
||||
serverPort: number;
|
||||
serverPassword: string;
|
||||
constructor(optionsArg: ISmartsocketClientOptions);
|
||||
serverCall(functionNameArg: string, dataArg: ISocketFunctionCall): void;
|
||||
private _handleSocketConnection();
|
||||
serverCall(functionNameArg: string, dataArg: ISocketFunctionCall): plugins.q.Promise<{}>;
|
||||
}
|
||||
|
39
dist/smartsocket.classes.smartsocketclient.js
vendored
39
dist/smartsocket.classes.smartsocketclient.js
vendored
@ -1,12 +1,40 @@
|
||||
"use strict";
|
||||
const plugins = require("./smartsocket.plugins");
|
||||
// import classes
|
||||
const smartsocket_classes_socketconnection_1 = require("./smartsocket.classes.socketconnection");
|
||||
const smartsocket_classes_socketrequest_1 = require("./smartsocket.classes.socketrequest");
|
||||
class SmartsocketClient {
|
||||
constructor(optionsArg) {
|
||||
// TODO: implement Socket init
|
||||
this.serverUrl = optionsArg.url;
|
||||
this.serverPort = optionsArg.port;
|
||||
this.serverPassword = optionsArg.password;
|
||||
}
|
||||
;
|
||||
// authenticates the socket against the server
|
||||
_handleSocketConnection() {
|
||||
let done = plugins.q.defer();
|
||||
let socketUrl = `${this.serverUrl}:${this.serverPort}`;
|
||||
this.socketConnection = new smartsocket_classes_socketconnection_1.SocketConnection({
|
||||
authenticated: false,
|
||||
socket: plugins.socketIoClient(this.serverUrl, {})
|
||||
});
|
||||
this.socketConnection.socket.on("requestAuth", function () {
|
||||
console.log("server requested authentication");
|
||||
this.socketConnection.socket.emit("dataAuth", {
|
||||
role: "coreflowContainer",
|
||||
password: "somePassword",
|
||||
alias: "coreflow1"
|
||||
});
|
||||
this.socketConnection.socket.on("authenticated", () => {
|
||||
console.log("client is authenticated");
|
||||
done.resolve();
|
||||
});
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
;
|
||||
serverCall(functionNameArg, dataArg) {
|
||||
let done = plugins.q.defer();
|
||||
let socketRequest = new smartsocket_classes_socketrequest_1.SocketRequest({
|
||||
side: "requesting",
|
||||
originSocketConnection: this.socketConnection,
|
||||
@ -16,8 +44,13 @@ class SmartsocketClient {
|
||||
funcDataArg: dataArg
|
||||
}
|
||||
});
|
||||
socketRequest.dispatch();
|
||||
socketRequest.dispatch()
|
||||
.then(() => {
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
}
|
||||
;
|
||||
}
|
||||
exports.SmartsocketClient = SmartsocketClient;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zbWFydHNvY2tldGNsaWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmNsYXNzZXMuc21hcnRzb2NrZXRjbGllbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHVCQUl6QixDQUFDLENBSitDO0FBVWhELG9EQUE4QixxQ0FBcUMsQ0FBQyxDQUFBO0FBU3BFO0lBRUksWUFBWSxVQUFvQztRQUM1Qyw4QkFBOEI7SUFDbEMsQ0FBQzs7SUFDRCxVQUFVLENBQUMsZUFBc0IsRUFBQyxPQUEyQjtRQUN6RCxJQUFJLGFBQWEsR0FBRyxJQUFJLGlEQUFhLENBQUM7WUFDbEMsSUFBSSxFQUFDLFlBQVk7WUFDakIsc0JBQXNCLEVBQUMsSUFBSSxDQUFDLGdCQUFnQjtZQUM1QyxPQUFPLEVBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxRQUFRLEVBQUU7WUFDbEMsWUFBWSxFQUFDO2dCQUNULFFBQVEsRUFBRSxlQUFlO2dCQUN6QixXQUFXLEVBQUMsT0FBTzthQUN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SxFQUFDO2dCQUNULFFBQVEsRUFBRSxlQUFlO2dCQUN6QixXQUFXLEVBQUMsT0FBTzthQUN0QjtTQUNKLENBQUMsQ0FBQztRQUNILGFBQWEsQ0FBQyxRQUFRLEVBQUU7YUFDbkIsSUFBSSxDQUFDO1lBQ0YsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO1FBQ25CLENBQUMsQ0FBQyxDQUFDO1FBQ1AsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQzs7QUFFTCxDQUFDO0FBbkRZLHlCQUFpQixvQkFtRDdCLENBQUEifQ==
|
@ -1,15 +1,16 @@
|
||||
/// <reference types="socket.io" />
|
||||
/// <reference types="socket.io-client" />
|
||||
/// <reference types="q" />
|
||||
import * as plugins from "./smartsocket.plugins";
|
||||
import { SocketRole } from "./smartsocket.classes.socketrole";
|
||||
/**
|
||||
* interface for constructor of class SocketConnection
|
||||
*/
|
||||
export interface ISocketConnectionOptions {
|
||||
export interface ISocketConnectionConstructorOptions {
|
||||
alias?: string;
|
||||
authenticated: boolean;
|
||||
role?: SocketRole;
|
||||
socket: SocketIO.Socket;
|
||||
socket?: SocketIO.Socket | SocketIOClient.Socket;
|
||||
}
|
||||
/**
|
||||
* interface for authentication data
|
||||
@ -26,8 +27,8 @@ export declare class SocketConnection {
|
||||
alias?: string;
|
||||
authenticated: boolean;
|
||||
role?: SocketRole;
|
||||
socket: SocketIO.Socket;
|
||||
constructor(optionsArg: ISocketConnectionOptions);
|
||||
socket: SocketIO.Socket | SocketIOClient.Socket;
|
||||
constructor(optionsArg: ISocketConnectionConstructorOptions);
|
||||
/**
|
||||
* authenticate the socket
|
||||
*/
|
||||
|
11
dist/smartsocket.classes.socketconnection.js
vendored
11
dist/smartsocket.classes.socketconnection.js
vendored
@ -14,6 +14,7 @@ class SocketConnection {
|
||||
this.role = optionsArg.role;
|
||||
this.socket = optionsArg.socket;
|
||||
}
|
||||
// authenticating --------------------------
|
||||
/**
|
||||
* authenticate the socket
|
||||
*/
|
||||
@ -25,7 +26,7 @@ class SocketConnection {
|
||||
if ((true)) {
|
||||
this.alias = dataArg.alias;
|
||||
this.authenticated = true;
|
||||
this.role = helpers.findSocketRoleByString(dataArg.role);
|
||||
this.role = helpers.getSocketRoleByName(dataArg.role);
|
||||
this.socket.emit("authenticated");
|
||||
plugins.beautylog.ok(`socket with >>alias ${this.alias} >>role ${this.role} is authenticated!`);
|
||||
done.resolve(this);
|
||||
@ -40,6 +41,7 @@ class SocketConnection {
|
||||
return done.promise;
|
||||
}
|
||||
;
|
||||
// listening -------------------------------
|
||||
/**
|
||||
* listen to function requests
|
||||
*/
|
||||
@ -58,7 +60,7 @@ class SocketConnection {
|
||||
shortId: dataArg.shortId,
|
||||
funcCallData: dataArg.funcCallData
|
||||
});
|
||||
localSocketRequest;
|
||||
localSocketRequest.createResponse(); // takes care of creating response and sending it back
|
||||
}
|
||||
else {
|
||||
plugins.beautylog.warn("function not existent or out of access scope");
|
||||
@ -66,6 +68,8 @@ class SocketConnection {
|
||||
;
|
||||
});
|
||||
this.socket.on("functionResponse", (dataArg) => {
|
||||
let targetSocketRequest = helpers.getSocketRequestById(dataArg.shortId);
|
||||
targetSocketRequest.handleResponse(dataArg);
|
||||
});
|
||||
}
|
||||
else {
|
||||
@ -74,7 +78,8 @@ class SocketConnection {
|
||||
;
|
||||
return done.promise;
|
||||
}
|
||||
;
|
||||
}
|
||||
exports.SocketConnection = SocketConnection;
|
||||
;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRjb25uZWN0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRjb25uZWN0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0F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LENBQUMsQ0FBQztRQUMxRCxDQUFDO1FBQUEsQ0FBQztRQUNGLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7O0FBSUwsQ0FBQztBQTNFWSx3QkFBZ0IsbUJBMkU1QixDQUFBO0FBQUEsQ0FBQyJ9
|
18
dist/smartsocket.classes.socketfunction.d.ts
vendored
18
dist/smartsocket.classes.socketfunction.d.ts
vendored
@ -1,32 +1,40 @@
|
||||
/// <reference types="q" />
|
||||
import * as plugins from "./smartsocket.plugins";
|
||||
import { Objectmap } from "lik";
|
||||
import { SocketRole } from "./smartsocket.classes.socketrole";
|
||||
/**
|
||||
* interface of the contructor options of class SocketFunction
|
||||
*/
|
||||
export interface ISocketFunctionOptions {
|
||||
export interface ISocketFunctionConstructorOptions {
|
||||
funcName: string;
|
||||
funcDef: any;
|
||||
allowedRoles: SocketRole[];
|
||||
}
|
||||
/**
|
||||
* interface of the Socket Function call
|
||||
* interface of the Socket Function call, in other words the object that routes a call to a function
|
||||
*/
|
||||
export interface ISocketFunctionCall {
|
||||
funcName: string;
|
||||
funcDataArg: any;
|
||||
}
|
||||
/**
|
||||
* interface for function definition of SocketFunction
|
||||
*/
|
||||
export interface IFuncDef {
|
||||
(dataArg: any): PromiseLike<any>;
|
||||
}
|
||||
export declare let allSocketFunctions: Objectmap<SocketFunction>;
|
||||
/**
|
||||
* class that respresents a function that can be transparently called using a SocketConnection
|
||||
*/
|
||||
export declare class SocketFunction {
|
||||
name: string;
|
||||
func: any;
|
||||
funcDef: IFuncDef;
|
||||
roles: SocketRole[];
|
||||
/**
|
||||
* the constructor for SocketFunction
|
||||
*/
|
||||
constructor(optionsArg: ISocketFunctionOptions);
|
||||
constructor(optionsArg: ISocketFunctionConstructorOptions);
|
||||
/**
|
||||
* notifies a role about access to this SocketFunction
|
||||
*/
|
||||
@ -34,5 +42,5 @@ export declare class SocketFunction {
|
||||
/**
|
||||
* invokes the function of this SocketFunction
|
||||
*/
|
||||
invoke(dataArg: any): plugins.q.Promise<any>;
|
||||
invoke(dataArg: ISocketFunctionCall): plugins.q.Promise<any>;
|
||||
}
|
||||
|
20
dist/smartsocket.classes.socketfunction.js
vendored
20
dist/smartsocket.classes.socketfunction.js
vendored
@ -1,6 +1,11 @@
|
||||
"use strict";
|
||||
const plugins = require("./smartsocket.plugins");
|
||||
// import classes
|
||||
const lik_1 = require("lik");
|
||||
;
|
||||
;
|
||||
// export objects
|
||||
exports.allSocketFunctions = new lik_1.Objectmap();
|
||||
// export classes
|
||||
/**
|
||||
* class that respresents a function that can be transparently called using a SocketConnection
|
||||
@ -11,11 +16,13 @@ class SocketFunction {
|
||||
*/
|
||||
constructor(optionsArg) {
|
||||
this.name = optionsArg.funcName;
|
||||
this.func = optionsArg.funcDef;
|
||||
this.funcDef = optionsArg.funcDef;
|
||||
this.roles = optionsArg.allowedRoles;
|
||||
for (let socketRoleArg of this.roles) {
|
||||
this._notifyRole(socketRoleArg);
|
||||
}
|
||||
;
|
||||
exports.allSocketFunctions.add(this); // map instance with Objectmap
|
||||
}
|
||||
;
|
||||
/**
|
||||
@ -29,9 +36,18 @@ class SocketFunction {
|
||||
*/
|
||||
invoke(dataArg) {
|
||||
let done = plugins.q.defer();
|
||||
if (dataArg.funcName === this.name) {
|
||||
this.funcDef(dataArg.funcDataArg)
|
||||
.then((resultData) => {
|
||||
done.resolve(resultData);
|
||||
});
|
||||
}
|
||||
else {
|
||||
throw new Error("SocketFunction.name does not match the data argument's .name!");
|
||||
}
|
||||
return done.promise;
|
||||
}
|
||||
;
|
||||
}
|
||||
exports.SocketFunction = SocketFunction;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRmdW5jdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmNsYXNzZXMuc29ja2V0ZnVuY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BTyxDQUFDLFFBQVEsS0FBSyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUEsQ0FBQztZQUMvQixJQUFJLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUM7aUJBQzVCLElBQUksQ0FBQyxDQUFDLFVBQWM7Z0JBQ2pCLElBQUksQ0FBQyxPQUFPLENBQUMsVUFBVSxDQUFDLENBQUM7WUFDN0IsQ0FBQyxDQUFDLENBQUM7UUFFWCxDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDSixNQUFNLElBQUksS0FBSyxDQUFDLCtEQUErRCxDQUFDLENBQUM7UUFDckYsQ0FBQztRQUNELE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7O0FBRUwsQ0FBQztBQTFDWSxzQkFBYyxpQkEwQzFCLENBQUEifQ==
|
16
dist/smartsocket.classes.socketrequest.d.ts
vendored
16
dist/smartsocket.classes.socketrequest.d.ts
vendored
@ -22,17 +22,25 @@ export interface ISocketRequestDataObject {
|
||||
shortId: string;
|
||||
responseTimeout?: number;
|
||||
}
|
||||
export declare let allRequestingSocketRequests: Objectmap<SocketRequest>;
|
||||
export declare let allRespondingSocketRequests: Objectmap<SocketRequest>;
|
||||
export declare let allSocketRequests: Objectmap<SocketRequest>;
|
||||
export declare class SocketRequest {
|
||||
status: TSocketRequestStatus;
|
||||
side: TSocketRequestSide;
|
||||
shortid: string;
|
||||
originSocketConnection: SocketConnection;
|
||||
requestData: ISocketRequestDataObject;
|
||||
funcCallData: ISocketFunctionCall;
|
||||
done: plugins.q.Deferred<{}>;
|
||||
constructor(optionsArg: SocketRequestConstructorOptions);
|
||||
/**
|
||||
* dispatches a socketrequest from the requesting to the receiving side
|
||||
*/
|
||||
dispatch(): plugins.q.Promise<{}>;
|
||||
/**
|
||||
* handles the response that is received by the requesting side
|
||||
*/
|
||||
handleResponse(responseDataArg: ISocketRequestDataObject): void;
|
||||
respond(dataArg: any): void;
|
||||
/**
|
||||
* creates the response on the responding side
|
||||
*/
|
||||
createResponse(): void;
|
||||
}
|
||||
|
51
dist/smartsocket.classes.socketrequest.js
vendored
51
dist/smartsocket.classes.socketrequest.js
vendored
@ -1,12 +1,12 @@
|
||||
"use strict";
|
||||
const plugins = require("./smartsocket.plugins");
|
||||
const helpers = require("./smartsocket.helpers");
|
||||
// import classes
|
||||
const lik_1 = require("lik");
|
||||
;
|
||||
;
|
||||
//export objects
|
||||
exports.allRequestingSocketRequests = new lik_1.Objectmap();
|
||||
exports.allRespondingSocketRequests = new lik_1.Objectmap();
|
||||
exports.allSocketRequests = new lik_1.Objectmap();
|
||||
// export classes
|
||||
class SocketRequest {
|
||||
constructor(optionsArg) {
|
||||
@ -14,32 +14,47 @@ class SocketRequest {
|
||||
this.done = plugins.q.defer();
|
||||
this.side = optionsArg.side;
|
||||
this.shortid = optionsArg.shortId;
|
||||
if (this.side === "requesting") {
|
||||
exports.allRequestingSocketRequests.add(this);
|
||||
}
|
||||
else {
|
||||
exports.allRespondingSocketRequests.add(this);
|
||||
}
|
||||
;
|
||||
// build request and response dataArg
|
||||
this.requestData = {
|
||||
funcCallData: optionsArg.funcCallData,
|
||||
shortId: optionsArg.shortId
|
||||
};
|
||||
this.funcCallData = optionsArg.funcCallData;
|
||||
exports.allSocketRequests.add(this);
|
||||
}
|
||||
;
|
||||
// requesting --------------------------
|
||||
/**
|
||||
* dispatches a socketrequest from the requesting to the receiving side
|
||||
*/
|
||||
dispatch() {
|
||||
this.originSocketConnection.socket.emit("function", this.requestData);
|
||||
let requestData = {
|
||||
funcCallData: this.funcCallData,
|
||||
shortId: this.shortid
|
||||
};
|
||||
this.originSocketConnection.socket.emit("function", requestData);
|
||||
return this.done.promise;
|
||||
}
|
||||
;
|
||||
/**
|
||||
* handles the response that is received by the requesting side
|
||||
*/
|
||||
handleResponse(responseDataArg) {
|
||||
this.done.resolve(responseDataArg);
|
||||
exports.allSocketRequests.remove(this);
|
||||
}
|
||||
respond(dataArg) {
|
||||
// responding --------------------------
|
||||
/**
|
||||
* creates the response on the responding side
|
||||
*/
|
||||
createResponse() {
|
||||
let targetSocketFunction = helpers.getSocketFunctionByName(this.funcCallData.funcName);
|
||||
targetSocketFunction.invoke(this.funcCallData)
|
||||
.then((resultData) => {
|
||||
let requestData = {
|
||||
funcCallData: resultData,
|
||||
shortId: this.shortid
|
||||
};
|
||||
this.originSocketConnection.socket.emit("functionResponse", requestData);
|
||||
exports.allSocketRequests.remove(this);
|
||||
});
|
||||
}
|
||||
;
|
||||
}
|
||||
exports.SocketRequest = SocketRequest;
|
||||
;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRyZXF1ZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRyZXF1ZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSx1QkFBdUIsQ0FBQyxDQUFBO0FBS2pELGlCQUFpQjtBQUNqQixzQkFBMEIsS0FBSyxDQUFDLENBQUE7QUFnQi9CLENBQUM7QUFTRCxDQUFDO0FBRUYsZ0JBQWdCO0FBQ0wsbUNBQTJCLEdBQUcsSUFBSSxlQUFTLEVBQWlCLENBQUM7QUFDN0QsbUNBQTJCLEdBQUcsSUFBSSxlQUFTLEVBQWlCLENBQUM7QUFFeEUsaUJBQWlCO0FBQ2pCO0lBT0ksWUFBWSxVQUEyQztRQU52RCxXQUFNLEdBQXlCLEtBQUssQ0FBQztRQUtyQyxTQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUVyQixJQUFJLENBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQyxJQUFJLENBQUM7UUFDNUIsSUFBSSxDQUFDLE9B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FBQztJQUM3QixDQUFDOztJQUVEOztPQUVHO0lBQ0gsY0FBYyxDQUFDLGVBQXlDO1FBQ3BELElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLGVBQWUsQ0FBQyxDQUFDO1FBQ25DLHlCQUFpQixDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUNuQyxDQUFDO0lBRUQsd0NBQXdDO0lBRXhDOztPQUVHO0lBQ0gsY0FBYztRQUNWLElBQUksb0JBQW9CLEdBQW1CLE9BQU8sQ0FBQyx1QkFBdUIsQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLFFBQVEsQ0FBQyxDQUFDO1FBQ3ZHLG9CQUFvQixDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDO2FBQ3pDLElBQUksQ0FBQyxDQUFDLFVBQVU7WUFDYixJQUFJLFdBQVcsR0FBNkI7Z0JBQ3hDLFlBQVksRUFBRSxVQUFVO2dCQUN4QixPQUFPLEVBQUUsSUFBSSxDQUFDLE9BQU87YUFDeEIsQ0FBQTtZQUNELElBQUksQ0FBQyxzQkFBc0IsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLGtCQUFrQixFQUFDLFdBQVcsQ0FBQyxDQUFDO1lBQ3hFLHlCQUFpQixDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUNuQyxDQUFDLENBQUMsQ0FBQztJQUNYLENBQUM7QUFDTCxDQUFDO0FBckRZLHFCQUFhLGdCQXFEekIsQ0FBQTtBQUFBLENBQUMifQ==
|
12
dist/smartsocket.helpers.d.ts
vendored
12
dist/smartsocket.helpers.d.ts
vendored
@ -1,2 +1,12 @@
|
||||
import { SocketFunction } from "./smartsocket.classes.socketfunction";
|
||||
import { SocketRequest } from "./smartsocket.classes.socketrequest";
|
||||
import { SocketRole } from "./smartsocket.classes.socketrole";
|
||||
export declare let findSocketRoleByString: (socketRoleNameArg: string) => SocketRole;
|
||||
export declare let getSocketFunctionByName: (functionNameArg: string) => SocketFunction;
|
||||
/**
|
||||
* get corresponding Socketrequest instance by shortId
|
||||
*/
|
||||
export declare let getSocketRequestById: (shortIdArg: string, requestSide?: "requesting" | "responding") => SocketRequest;
|
||||
/**
|
||||
* get corresponding SocketRole instance by name
|
||||
*/
|
||||
export declare let getSocketRoleByName: (socketRoleNameArg: string) => SocketRole;
|
||||
|
20
dist/smartsocket.helpers.js
vendored
20
dist/smartsocket.helpers.js
vendored
@ -1,7 +1,23 @@
|
||||
"use strict";
|
||||
const smartsocket_classes_socketfunction_1 = require("./smartsocket.classes.socketfunction");
|
||||
const smartsocket_classes_socketrequest_1 = require("./smartsocket.classes.socketrequest");
|
||||
const smartsocket_classes_socketrole_1 = require("./smartsocket.classes.socketrole");
|
||||
// SocketFunction helpers
|
||||
exports.getSocketFunctionByName = (functionNameArg) => {
|
||||
return smartsocket_classes_socketfunction_1.allSocketFunctions.find((socketFunctionArg) => { return socketFunctionArg.name === functionNameArg; });
|
||||
};
|
||||
// SocketRequest helpers
|
||||
/**
|
||||
* get corresponding Socketrequest instance by shortId
|
||||
*/
|
||||
exports.getSocketRequestById = (shortIdArg, requestSide) => {
|
||||
return smartsocket_classes_socketrequest_1.allSocketRequests.find((socketRequestArg) => { return socketRequestArg.shortid === shortIdArg; });
|
||||
};
|
||||
// SocketRole helpers
|
||||
exports.findSocketRoleByString = (socketRoleNameArg) => {
|
||||
/**
|
||||
* get corresponding SocketRole instance by name
|
||||
*/
|
||||
exports.getSocketRoleByName = (socketRoleNameArg) => {
|
||||
return smartsocket_classes_socketrole_1.allSocketRoles.find((socketRoleArg) => { return socketRoleArg.name === socketRoleNameArg; });
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmhlbHBl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BQWdCLENBQUMsT0FBTyxLQUFLLFVBQVUsQ0FBQSxDQUFBLENBQUMsQ0FBQyxDQUFBO0FBQ3pHLENBQUMsQ0FBQTtBQUVELHFCQUFxQjtBQUVyQjs7R0FFRztBQUNRLDJCQUFtQixHQUFHLENBQUMsaUJBQXlCO0lBQ3ZELE1BQU0sQ0FBQywrQ0FBYyxDQUFDLElBQUksQ0FBQyxDQUFDLGFBQWEsT0FBTyxNQUFNLENBQUMsYUFBYSxDQUFDLElBQUksS0FBSyxpQkFBaUIsQ0FBQSxDQUFDLENBQUMsQ0FBQyxDQUFBO0FBQ3RHLENBQUMsQ0FBQyJ9
|
32
test/test.ts
32
test/test.ts
@ -4,35 +4,33 @@ import socketIoClient = require("socket.io-client");
|
||||
import smartsocket = require("../dist/index");
|
||||
|
||||
let testSmartsocket: smartsocket.Smartsocket;
|
||||
let testSmartsocketClient: smartsocket.SmartsocketClient;
|
||||
|
||||
let testConfig = {
|
||||
port:3000
|
||||
}
|
||||
|
||||
describe("smartsocket", function () {
|
||||
it("should create a new smartsocket", function () {
|
||||
testSmartsocket = new smartsocket.Smartsocket({ port: 3000 });
|
||||
testSmartsocket = new smartsocket.Smartsocket({ port: testConfig.port });
|
||||
testSmartsocket.should.be.instanceOf(smartsocket.Smartsocket);
|
||||
});
|
||||
it("should register a new Function",function(){
|
||||
it("should register a new Function", function () {
|
||||
|
||||
})
|
||||
it("should start listening when .started is called",function(){
|
||||
it("should start listening when .started is called", function () {
|
||||
testSmartsocket.startServer();
|
||||
})
|
||||
it("should react to a new websocket connection", function (done) {
|
||||
this.timeout(10000);
|
||||
let socket = socketIoClient("http://localhost:3000", {});
|
||||
socket.on("requestAuth", function () {
|
||||
console.log("server requested authentication");
|
||||
socket.emit("dataAuth", {
|
||||
role: "coreflowContainer",
|
||||
password: "somePassword",
|
||||
alias: "coreflow1"
|
||||
});
|
||||
socket.on("authenticated",() => {
|
||||
console.log("client is authenticated");
|
||||
done();
|
||||
});
|
||||
testSmartsocketClient = new smartsocket.SmartsocketClient({
|
||||
port: testConfig.port,
|
||||
url: "http://localhost",
|
||||
password:"testPassword",
|
||||
alias: "testClient1"
|
||||
});
|
||||
});
|
||||
it("should close the server",function(){
|
||||
it("should close the server", function () {
|
||||
testSmartsocket.closeServer();
|
||||
})
|
||||
});
|
||||
});
|
@ -69,6 +69,7 @@ export class SocketRequest {
|
||||
*/
|
||||
handleResponse(responseDataArg: ISocketRequestDataObject) {
|
||||
this.done.resolve(responseDataArg);
|
||||
allSocketRequests.remove(this);
|
||||
}
|
||||
|
||||
// responding --------------------------
|
||||
@ -85,6 +86,7 @@ export class SocketRequest {
|
||||
shortId: this.shortid
|
||||
}
|
||||
this.originSocketConnection.socket.emit("functionResponse",requestData);
|
||||
allSocketRequests.remove(this);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user