diff --git a/dist/smartsocket.classes.smartsocketclient.d.ts b/dist/smartsocket.classes.smartsocketclient.d.ts
index 878b239..cc0e2e2 100644
--- a/dist/smartsocket.classes.smartsocketclient.d.ts
+++ b/dist/smartsocket.classes.smartsocketclient.d.ts
@@ -1,6 +1,5 @@
-///
-import * as plugins from "./smartsocket.plugins";
-import { ISocketFunctionRequestObject, ISocketFunctionResponseObject } from "./smartsocket.classes.socketfunction";
+import { ISocketFunctionCall } from "./smartsocket.classes.socketfunction";
+import { SocketConnection } from "./smartsocket.classes.socketconnection";
/**
* interface for class SmartsocketClient
*/
@@ -9,6 +8,7 @@ export interface ISmartsocketClientOptions {
url: string;
}
export declare class SmartsocketClient {
- constructor();
- dispatchFunctionRequest(dataArg: ISocketFunctionRequestObject): plugins.q.Promise;
+ socketConnection: SocketConnection;
+ constructor(optionsArg: ISmartsocketClientOptions);
+ serverCall(functionNameArg: string, dataArg: ISocketFunctionCall): void;
}
diff --git a/dist/smartsocket.classes.smartsocketclient.js b/dist/smartsocket.classes.smartsocketclient.js
index 67ebea2..3cc344e 100644
--- a/dist/smartsocket.classes.smartsocketclient.js
+++ b/dist/smartsocket.classes.smartsocketclient.js
@@ -1,15 +1,23 @@
"use strict";
const plugins = require("./smartsocket.plugins");
+const smartsocket_classes_socketrequest_1 = require("./smartsocket.classes.socketrequest");
class SmartsocketClient {
- constructor() {
- }
- dispatchFunctionRequest(dataArg) {
- let done = plugins.q.defer();
- let responseData;
- done.resolve(responseData);
- return done.promise;
+ constructor(optionsArg) {
+ // TODO: implement Socket init
}
;
+ serverCall(functionNameArg, dataArg) {
+ let socketRequest = new smartsocket_classes_socketrequest_1.SocketRequest({
+ side: "requesting",
+ originSocketConnection: this.socketConnection,
+ shortId: plugins.shortid.generate(),
+ funcCallData: {
+ funcName: functionNameArg,
+ funcDataArg: dataArg
+ }
+ });
+ socketRequest.dispatch();
+ }
}
exports.SmartsocketClient = SmartsocketClient;
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJ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EsR0FBRyxJQUFJLGlEQUFhLENBQUM7WUFDbEMsSUFBSSxFQUFDLFlBQVk7WUFDakIsc0JBQXNCLEVBQUMsSUFBSSxDQUFDLGdCQUFnQjtZQUM1QyxPQUFPLEVBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxRQUFRLEVBQUU7WUFDbEMsWUFBWSxFQUFDO2dCQUNULFFBQVEsRUFBRSxlQUFlO2dCQUN6QixXQUFXLEVBQUMsT0FBTzthQUN0QjtTQUNKLENBQUMsQ0FBQztRQUNILGFBQWEsQ0FBQyxRQUFRLEVBQUUsQ0FBQztJQUM3QixDQUFDO0FBRUwsQ0FBQztBQWxCWSx5QkFBaUIsb0JBa0I3QixDQUFBIn0=
\ No newline at end of file
diff --git a/dist/smartsocket.classes.socketconnection.js b/dist/smartsocket.classes.socketconnection.js
index ed44ea3..d18c639 100644
--- a/dist/smartsocket.classes.socketconnection.js
+++ b/dist/smartsocket.classes.socketconnection.js
@@ -47,15 +47,18 @@ class SocketConnection {
let done = plugins.q.defer();
if (this.authenticated) {
this.socket.on("function", (dataArg) => {
+ // check if requested function is available to the socket's scope
let referencedFunction = this.role.allowedFunctions.find((socketFunctionArg) => {
- return socketFunctionArg.name === dataArg.functionName;
+ return socketFunctionArg.name === dataArg.funcCallData.funcName;
});
if (referencedFunction !== undefined) {
let localSocketRequest = new smartsocket_classes_socketrequest_1.SocketRequest({
side: "responding",
- shortid: dataArg.shortId,
- requestData: dataArg
+ originSocketConnection: this,
+ shortId: dataArg.shortId,
+ funcCallData: dataArg.funcCallData
});
+ localSocketRequest;
}
else {
plugins.beautylog.warn("function not existent or out of access scope");
@@ -74,4 +77,4 @@ class SocketConnection {
}
exports.SocketConnection = SocketConnection;
;
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRjb25uZWN0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsi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socket.classes.socketfunction.d.ts b/dist/smartsocket.classes.socketfunction.d.ts
index 1508bf4..131b542 100644
--- a/dist/smartsocket.classes.socketfunction.d.ts
+++ b/dist/smartsocket.classes.socketfunction.d.ts
@@ -1,21 +1,23 @@
+///
+import * as plugins from "./smartsocket.plugins";
import { SocketRole } from "./smartsocket.classes.socketrole";
-export interface ISocketFunctionRequestObject {
- functionName: string;
- argumentObject: any;
- shortId: string;
- responseTimeout?: number;
-}
-export interface ISocketFunctionResponseObject {
- shortId: string;
- argumentObject: any;
-}
-export interface SocketFunctionOptions {
- name: string;
- func: any;
- roles: SocketRole[];
+/**
+ * interface of the contructor options of class SocketFunction
+ */
+export interface ISocketFunctionOptions {
+ funcName: string;
+ funcDef: any;
+ allowedRoles: SocketRole[];
}
/**
- * class SocketFunction respresents a function that can be transparently called using a SocketConnection
+ * interface of the Socket Function call
+ */
+export interface ISocketFunctionCall {
+ funcName: string;
+ funcDataArg: any;
+}
+/**
+ * class that respresents a function that can be transparently called using a SocketConnection
*/
export declare class SocketFunction {
name: string;
@@ -24,7 +26,7 @@ export declare class SocketFunction {
/**
* the constructor for SocketFunction
*/
- constructor(optionsArg: SocketFunctionOptions);
+ constructor(optionsArg: ISocketFunctionOptions);
/**
* notifies a role about access to this SocketFunction
*/
@@ -32,5 +34,5 @@ export declare class SocketFunction {
/**
* invokes the function of this SocketFunction
*/
- invoke(dataArg: ISocketFunctionRequestObject): void;
+ invoke(dataArg: any): plugins.q.Promise;
}
diff --git a/dist/smartsocket.classes.socketfunction.js b/dist/smartsocket.classes.socketfunction.js
index ab42167..297f43a 100644
--- a/dist/smartsocket.classes.socketfunction.js
+++ b/dist/smartsocket.classes.socketfunction.js
@@ -1,19 +1,18 @@
"use strict";
-;
-;
+const plugins = require("./smartsocket.plugins");
;
// export classes
/**
- * class SocketFunction respresents a function that can be transparently called using a SocketConnection
+ * class that 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;
- this.roles = optionsArg.roles;
+ this.name = optionsArg.funcName;
+ this.func = optionsArg.funcDef;
+ this.roles = optionsArg.allowedRoles;
for (let socketRoleArg of this.roles) {
this._notifyRole(socketRoleArg);
}
@@ -29,8 +28,10 @@ class SocketFunction {
* invokes the function of this SocketFunction
*/
invoke(dataArg) {
+ let done = plugins.q.defer();
+ return done.promise;
}
;
}
exports.SocketFunction = SocketFunction;
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRmdW5jdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmNsYXNzZXMuc29ja2V0ZnVuY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQWFDLENBQUM7QUFLRCxDQUFDO0FBTUQsQ0FBQztBQUVGLGlCQUFpQjtBQUVqQjs7R0FFRztBQUNIO0lBS0k7O09BRUc7SUFDSCxZQUFZLFVBQWlDO1FBQ3pDLElBQUksQ0FBQyxJQUFJLEdBQUcsVUFBVSxDQUFDLElBQUksQ0FBQztRQUM1QixJQUFJLENBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQyxJQUFJLENBQUM7UUFDNUIsSUFBSSxDQUFDLEtBQUssR0FBRyxVQUFVLENBQUMsS0FBSyxDQUFDO1FBQzlCLEdBQUcsQ0FBQyxDQUFDLElBQUksYUFBYSxJQUFJLElBQUksQ0FBQyxLQUFLLENBQUMsQ0FBQSxDQUFDO1lBQ2xDLElBQUksQ0FBQyxXQUFXLENBQUMsYUFBYSxDQUFDLENBQUM7UUFDcEMsQ0FBQztJQUNMLENBQUM7O0lBRUQ7O09BRUc7SUFDSyxXQUFXLENBQUMsYUFBd0I7UUFDeEMsYUFBYSxDQUFDLGlCQUFpQixDQUFDLElBQUksQ0FBQyxDQUFD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0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDN0IsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7SUFDeEIsQ0FBQzs7QUFFTCxDQUFDO0FBaENZLHNCQUFjLGlCQWdDMUIsQ0FBQSJ9
\ No newline at end of file
diff --git a/dist/smartsocket.classes.socketrequest.d.ts b/dist/smartsocket.classes.socketrequest.d.ts
index b39a0c5..d872fb9 100644
--- a/dist/smartsocket.classes.socketrequest.d.ts
+++ b/dist/smartsocket.classes.socketrequest.d.ts
@@ -1,12 +1,26 @@
-import { ISocketFunctionRequestObject, ISocketFunctionResponseObject } from "./smartsocket.classes.socketfunction";
+///
+import * as plugins from "./smartsocket.plugins";
+import { ISocketFunctionCall } from "./smartsocket.classes.socketfunction";
import { Objectmap } from "lik";
+import { SocketConnection } from "./smartsocket.classes.socketconnection";
export declare type TSocketRequestStatus = "new" | "pending" | "finished";
export declare type TSocketRequestSide = "requesting" | "responding";
+/**
+ * interface of constructor of class SocketRequest
+ */
export interface SocketRequestConstructorOptions {
side: TSocketRequestSide;
- shortid: string;
- requestData?: ISocketFunctionRequestObject;
- responseData?: ISocketFunctionResponseObject;
+ originSocketConnection: SocketConnection;
+ shortId: string;
+ funcCallData?: ISocketFunctionCall;
+}
+/**
+ * request object that is sent initially and may or may not receive a response
+ */
+export interface ISocketRequestDataObject {
+ funcCallData: ISocketFunctionCall;
+ shortId: string;
+ responseTimeout?: number;
}
export declare let allRequestingSocketRequests: Objectmap;
export declare let allRespondingSocketRequests: Objectmap;
@@ -14,12 +28,11 @@ export declare class SocketRequest {
status: TSocketRequestStatus;
side: TSocketRequestSide;
shortid: string;
- requestData: ISocketFunctionRequestObject;
- responseData: ISocketFunctionResponseObject;
+ originSocketConnection: SocketConnection;
+ requestData: ISocketRequestDataObject;
+ done: plugins.q.Deferred<{}>;
constructor(optionsArg: SocketRequestConstructorOptions);
- private _sendRequest(dataArg);
- private _receiveRequest(dataArg);
- private _sendResponse(dataArg);
- private _receiveResponse(dataArg);
- private _dispatch(dataArg);
+ dispatch(): plugins.q.Promise<{}>;
+ handleResponse(responseDataArg: ISocketRequestDataObject): void;
+ respond(dataArg: any): void;
}
diff --git a/dist/smartsocket.classes.socketrequest.js b/dist/smartsocket.classes.socketrequest.js
index 0b12e88..bf58b1c 100644
--- a/dist/smartsocket.classes.socketrequest.js
+++ b/dist/smartsocket.classes.socketrequest.js
@@ -1,7 +1,9 @@
"use strict";
+const plugins = require("./smartsocket.plugins");
// import classes
const lik_1 = require("lik");
;
+;
//export objects
exports.allRequestingSocketRequests = new lik_1.Objectmap();
exports.allRespondingSocketRequests = new lik_1.Objectmap();
@@ -9,10 +11,9 @@ exports.allRespondingSocketRequests = new lik_1.Objectmap();
class SocketRequest {
constructor(optionsArg) {
this.status = "new";
+ this.done = plugins.q.defer();
this.side = optionsArg.side;
- this.shortid = optionsArg.shortid;
- this.requestData = optionsArg.requestData;
- this.responseData = optionsArg.responseData;
+ this.shortid = optionsArg.shortId;
if (this.side === "requesting") {
exports.allRequestingSocketRequests.add(this);
}
@@ -20,23 +21,25 @@ class SocketRequest {
exports.allRespondingSocketRequests.add(this);
}
;
+ // build request and response dataArg
+ this.requestData = {
+ funcCallData: optionsArg.funcCallData,
+ shortId: optionsArg.shortId
+ };
}
;
- _sendRequest(dataArg) {
+ dispatch() {
+ this.originSocketConnection.socket.emit("function", this.requestData);
+ return this.done.promise;
}
;
- _receiveRequest(dataArg) {
+ handleResponse(responseDataArg) {
+ this.done.resolve(responseDataArg);
}
- ;
- _sendResponse(dataArg) {
- }
- _receiveResponse(dataArg) {
- }
- ;
- _dispatch(dataArg) {
+ respond(dataArg) {
}
;
}
exports.SocketRequest = SocketRequest;
;
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRyZXF1ZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4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QUFDLElBQUksQ0FBQyxDQUFDO1lBQ0osbUNBQTJCLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQzFDLENBQUM7UUFBQSxDQUFDO1FBQ0YscUNBQXFDO1FBQ3JDLElBQUksQ0FBQyxXQUFXLEdBQUc7WUFDZixZQUFZLEVBQUMsVUFBVSxDQUFDLFlBQVk7WUFDcEMsT0FBTyxFQUFDLFVBQVUsQ0FBQyxPQUFPO1NBQzdCLENBQUE7SUFDTCxDQUFDOztJQUNELFFBQVE7UUFDSixJQUFJLENBQUMsc0JBQXNCLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxVQUFVLEVBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFDO1FBQ3JFLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUM3QixDQUFDOztJQUNELGNBQWMsQ0FBQyxlQUF3QztRQUNuRCxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxlQUFlLENBQUMsQ0FBQztJQUN2QyxDQUFDO0lBQ0QsT0FBTyxDQUFDLE9BQU87SUFFZixDQUFDOztBQUNMLENBQUM7QUEvQlkscUJBQWEsZ0JBK0J6QixDQUFBO0FBQUEsQ0FBQyJ9
\ No newline at end of file
diff --git a/ts/smartsocket.classes.smartsocketclient.ts b/ts/smartsocket.classes.smartsocketclient.ts
index d1e086f..7e7b0c5 100644
--- a/ts/smartsocket.classes.smartsocketclient.ts
+++ b/ts/smartsocket.classes.smartsocketclient.ts
@@ -19,8 +19,8 @@ export interface ISmartsocketClientOptions {
export class SmartsocketClient {
socketConnection:SocketConnection;
- constructor(){
-
+ constructor(optionsArg:ISmartsocketClientOptions){
+ // TODO: implement Socket init
};
serverCall(functionNameArg:string,dataArg:ISocketFunctionCall){
let socketRequest = new SocketRequest({
@@ -30,9 +30,9 @@ export class SmartsocketClient {
funcCallData:{
funcName: functionNameArg,
funcDataArg:dataArg
-
}
});
+ socketRequest.dispatch();
}
}
\ No newline at end of file
diff --git a/ts/smartsocket.classes.socketconnection.ts b/ts/smartsocket.classes.socketconnection.ts
index a0abd78..0f394eb 100644
--- a/ts/smartsocket.classes.socketconnection.ts
+++ b/ts/smartsocket.classes.socketconnection.ts
@@ -74,16 +74,18 @@ export class SocketConnection {
let done = plugins.q.defer();
if(this.authenticated){
this.socket.on("function", (dataArg:ISocketRequestDataObject) => {
+ // check if requested function is available to the socket's scope
let referencedFunction:SocketFunction = this.role.allowedFunctions.find((socketFunctionArg) => {
- return socketFunctionArg.name === dataArg.funcName
+ return socketFunctionArg.name === dataArg.funcCallData.funcName;
});
if(referencedFunction !== undefined){
let localSocketRequest = new SocketRequest({
side:"responding",
originSocketConnection:this,
shortId:dataArg.shortId,
- requestData:dataArg
+ funcCallData:dataArg.funcCallData
});
+ localSocketRequest
} else {
plugins.beautylog.warn("function not existent or out of access scope");
};
diff --git a/ts/smartsocket.classes.socketrequest.ts b/ts/smartsocket.classes.socketrequest.ts
index ca08d49..ba99de5 100644
--- a/ts/smartsocket.classes.socketrequest.ts
+++ b/ts/smartsocket.classes.socketrequest.ts
@@ -13,15 +13,8 @@ export type TSocketRequestStatus = "new" | "pending" | "finished";
export type TSocketRequestSide = "requesting" | "responding";
/**
- * request object that is sent initially and may or may not receive a response
+ * interface of constructor of class SocketRequest
*/
-export interface ISocketRequestDataObject {
- funcName:string,
- funcDataArg:any,
- shortId:string,
- responseTimeout?:number
-};
-
export interface SocketRequestConstructorOptions {
side: TSocketRequestSide;
originSocketConnection:SocketConnection;
@@ -29,6 +22,15 @@ export interface SocketRequestConstructorOptions {
funcCallData?: ISocketFunctionCall;
};
+/**
+ * request object that is sent initially and may or may not receive a response
+ */
+export interface ISocketRequestDataObject {
+ funcCallData:ISocketFunctionCall;
+ shortId:string;
+ responseTimeout?:number;
+};
+
//export objects
export let allRequestingSocketRequests = new Objectmap();
export let allRespondingSocketRequests = new Objectmap();
@@ -40,7 +42,7 @@ export class SocketRequest {
shortid: string;
originSocketConnection:SocketConnection;
requestData: ISocketRequestDataObject;
- responseData: ISocketRequestDataObject;
+ done = plugins.q.defer();
constructor(optionsArg: SocketRequestConstructorOptions) {
this.side = optionsArg.side;
this.shortid = optionsArg.shortId;
@@ -49,25 +51,23 @@ export class SocketRequest {
} else {
allRespondingSocketRequests.add(this);
};
+ // build request and response dataArg
+ this.requestData = {
+ funcCallData:optionsArg.funcCallData,
+ shortId:optionsArg.shortId
+ }
};
-
- respond(dataArg){
+ /**
+ *
+ */
+ dispatch(){
+ this.originSocketConnection.socket.emit("function",this.requestData);
+ return this.done.promise;
+ };
+ handleResponse(responseDataArg:ISocketRequestDataObject){
+ this.done.resolve(responseDataArg);
+ }
+ createResponse(){
}
- // private functions
- private _sendRequest(dataArg:ISocketRequestDataObject){
-
- };
- private _receiveRequest(dataArg:ISocketRequestDataObject){
-
- };
- private _sendResponse(dataArg:ISocketRequestDataObject){
-
- }
- private _receiveResponse(dataArg:ISocketRequestDataObject){
-
- };
- private _dispatch(dataArg:ISocketRequestDataObject){ // note: dispatch is private as it will be fired from the constructor
-
- };
};