some more logic
request/response abstraction to make transparent function calls happen
This commit is contained in:
parent
f670cae1f8
commit
5109964247
11
dist/smartsocket.classes.socketconnection.js
vendored
11
dist/smartsocket.classes.socketconnection.js
vendored
@ -1,6 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const plugins = require("./smartsocket.plugins");
|
const plugins = require("./smartsocket.plugins");
|
||||||
const helpers = require("./smartsocket.helpers");
|
const helpers = require("./smartsocket.helpers");
|
||||||
|
const smartsocket_classes_socketrequest_1 = require("./smartsocket.classes.socketrequest");
|
||||||
;
|
;
|
||||||
// export classes
|
// export classes
|
||||||
/**
|
/**
|
||||||
@ -50,13 +51,19 @@ class SocketConnection {
|
|||||||
return socketFunctionArg.name === dataArg.functionName;
|
return socketFunctionArg.name === dataArg.functionName;
|
||||||
});
|
});
|
||||||
if (referencedFunction !== undefined) {
|
if (referencedFunction !== undefined) {
|
||||||
referencedFunction.invoke(dataArg);
|
let localSocketRequest = new smartsocket_classes_socketrequest_1.SocketRequest({
|
||||||
|
side: "responding",
|
||||||
|
shortid: dataArg.shortId,
|
||||||
|
requestData: dataArg
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plugins.beautylog.warn("function not existent or out of access scope");
|
plugins.beautylog.warn("function not existent or out of access scope");
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
});
|
});
|
||||||
|
this.socket.on("functionResponse", (dataArg) => {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
done.reject("socket needs to be authenticated first");
|
done.reject("socket needs to be authenticated first");
|
||||||
@ -67,4 +74,4 @@ class SocketConnection {
|
|||||||
}
|
}
|
||||||
exports.SocketConnection = SocketConnection;
|
exports.SocketConnection = SocketConnection;
|
||||||
;
|
;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRjb25uZWN0aW9uLmpzIiwic291cmNlUm9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yxJQUFJLGlEQUFhLENBQUM7d0JBQ3ZDLElBQUksRUFBQyxZQUFZO3dCQUNqQixPQUFPLEVBQUMsT0FBTyxDQUFDLE9BQU87d0JBQ3ZCLFdBQVcsRUFBQyxPQUFPO3FCQUN0QixDQUFDLENBQUM7Z0JBQ1AsQ0FBQztnQkFBQyxJQUFJLENBQUMsQ0FBQztvQkFDSixPQUFPLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyw4Q0FBOEMsQ0FBQyxDQUFDO2dCQUMzRSxDQUFDO2dCQUFBLENBQUM7WUFDTixDQUFDLENBQUMsQ0FBQztZQUNILElBQUksQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLGtCQUFrQixFQUFFLENBQUMsT0FBb0M7WUFFeEUsQ0FBQyxDQUFDLENBQUE7UUFDTixDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDSixJQUFJLENBQUMsTUFBTSxDQUFDLHdDQUF3QyxDQUFDLENBQUM7UUFDMUQsQ0FBQztRQUFBLENBQUM7UUFDRixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN4QixDQUFDO0FBQ0wsQ0FBQztBQS9EWSx3QkFBZ0IsbUJBK0Q1QixDQUFBO0FBQUEsQ0FBQyJ9
|
13
dist/smartsocket.classes.socketrequest.d.ts
vendored
13
dist/smartsocket.classes.socketrequest.d.ts
vendored
@ -1,10 +1,12 @@
|
|||||||
import { ISocketFunctionResponseObject } from "./smartsocket.classes.socketfunction";
|
import { ISocketFunctionRequestObject, ISocketFunctionResponseObject } from "./smartsocket.classes.socketfunction";
|
||||||
import { Objectmap } from "lik";
|
import { Objectmap } from "lik";
|
||||||
export declare type TSocketRequestStatus = "new" | "pending" | "finished";
|
export declare type TSocketRequestStatus = "new" | "pending" | "finished";
|
||||||
export declare type TSocketRequestSide = "requesting" | "responding";
|
export declare type TSocketRequestSide = "requesting" | "responding";
|
||||||
export interface SocketRequestConstructorOptions {
|
export interface SocketRequestConstructorOptions {
|
||||||
side: TSocketRequestSide;
|
side: TSocketRequestSide;
|
||||||
shortid: string;
|
shortid: string;
|
||||||
|
requestData?: ISocketFunctionRequestObject;
|
||||||
|
responseData?: ISocketFunctionResponseObject;
|
||||||
}
|
}
|
||||||
export declare let allRequestingSocketRequests: Objectmap<SocketRequest>;
|
export declare let allRequestingSocketRequests: Objectmap<SocketRequest>;
|
||||||
export declare let allRespondingSocketRequests: Objectmap<SocketRequest>;
|
export declare let allRespondingSocketRequests: Objectmap<SocketRequest>;
|
||||||
@ -12,7 +14,12 @@ export declare class SocketRequest {
|
|||||||
status: TSocketRequestStatus;
|
status: TSocketRequestStatus;
|
||||||
side: TSocketRequestSide;
|
side: TSocketRequestSide;
|
||||||
shortid: string;
|
shortid: string;
|
||||||
|
requestData: ISocketFunctionRequestObject;
|
||||||
|
responseData: ISocketFunctionResponseObject;
|
||||||
constructor(optionsArg: SocketRequestConstructorOptions);
|
constructor(optionsArg: SocketRequestConstructorOptions);
|
||||||
respond(dataArg: ISocketFunctionResponseObject): void;
|
private _sendRequest(dataArg);
|
||||||
private _dispatch();
|
private _receiveRequest(dataArg);
|
||||||
|
private _sendResponse(dataArg);
|
||||||
|
private _receiveResponse(dataArg);
|
||||||
|
private _dispatch(dataArg);
|
||||||
}
|
}
|
||||||
|
18
dist/smartsocket.classes.socketrequest.js
vendored
18
dist/smartsocket.classes.socketrequest.js
vendored
@ -11,6 +11,8 @@ class SocketRequest {
|
|||||||
this.status = "new";
|
this.status = "new";
|
||||||
this.side = optionsArg.side;
|
this.side = optionsArg.side;
|
||||||
this.shortid = optionsArg.shortid;
|
this.shortid = optionsArg.shortid;
|
||||||
|
this.requestData = optionsArg.requestData;
|
||||||
|
this.responseData = optionsArg.responseData;
|
||||||
if (this.side === "requesting") {
|
if (this.side === "requesting") {
|
||||||
exports.allRequestingSocketRequests.add(this);
|
exports.allRequestingSocketRequests.add(this);
|
||||||
}
|
}
|
||||||
@ -20,11 +22,21 @@ class SocketRequest {
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
respond(dataArg) {
|
_sendRequest(dataArg) {
|
||||||
}
|
}
|
||||||
_dispatch() {
|
;
|
||||||
|
_receiveRequest(dataArg) {
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
_sendResponse(dataArg) {
|
||||||
|
}
|
||||||
|
_receiveResponse(dataArg) {
|
||||||
|
}
|
||||||
|
;
|
||||||
|
_dispatch(dataArg) {
|
||||||
|
}
|
||||||
|
;
|
||||||
}
|
}
|
||||||
exports.SocketRequest = SocketRequest;
|
exports.SocketRequest = SocketRequest;
|
||||||
;
|
;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRyZXF1ZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRyZXF1ZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFLQSxpQkFBaUI7QUFDakIsc0JBQTBCLEtBQUssQ0FBQyxDQUFBO0FBVS9CLENBQUM7QUFFRixnQkFBZ0I7QUFDTCxtQ0FBMkIsR0FBRyxJQUFJLGVBQVMsRUFBaUIsQ0FBQztBQUM3RCxtQ0FBMkIsR0FBRyxJQUFJLGVBQVMsRUFBaUIsQ0FBQztBQUV4RSxpQkFBaUI7QUFDakI7SUFJSSxZQUFZLFVBQTJDO1FBSHZELFdBQU0sR0FBeUIsS0FBSyxDQUFDO1FBSWpDLElBQUksQ0FBQyxJQUFJLEdBQUcsVUFBVSxDQUFDLElBQUksQ0FBQztRQUM1QixJQUFJLENBQUMsT0FBTyxHQUFHLFVBQVUsQ0FBQyxPQUFPLENBQUM7UUFDbEMsRUFBRSxDQUFBLENBQUMsSUFBSSxDQUFDLElBQUksS0FBSyxZQUFZLENBQUMsQ0FBQSxDQUFDO1lBQz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VUFBVSxDQUFDLFlBQVksQ0FBQztRQUM1QyxFQUFFLENBQUEsQ0FBQyxJQUFJLENBQUMsSUFBSSxLQUFLLFlBQVksQ0FBQyxDQUFBLENBQUM7WUFDM0IsbUNBQTJCLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQzFDLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLG1DQUEyQixDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUMxQyxDQUFDO1FBQUEsQ0FBQztJQUNOLENBQUM7O0lBRU8sWUFBWSxDQUFDLE9BQW9DO0lBRXpELENBQUM7O0lBQ08sZUFBZSxDQUFDLE9BQW9DO0lBRTVELENBQUM7O0lBQ08sYUFBYSxDQUFDLE9BQXFDO0lBRTNELENBQUM7SUFDTyxnQkFBZ0IsQ0FBQyxPQUFxQztJQUU5RCxDQUFDOztJQUNPLFNBQVMsQ0FBQyxPQUFvQztJQUV0RCxDQUFDOztBQUNMLENBQUM7QUFqQ1kscUJBQWEsZ0JBaUN6QixDQUFBO0FBQUEsQ0FBQyJ9
|
@ -78,10 +78,17 @@ export class SocketConnection {
|
|||||||
return socketFunctionArg.name === dataArg.functionName
|
return socketFunctionArg.name === dataArg.functionName
|
||||||
});
|
});
|
||||||
if(referencedFunction !== undefined){
|
if(referencedFunction !== undefined){
|
||||||
referencedFunction.invoke(dataArg);
|
let localSocketRequest = new SocketRequest({
|
||||||
|
side:"responding",
|
||||||
|
shortid:dataArg.shortId,
|
||||||
|
requestData:dataArg
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
plugins.beautylog.warn("function not existent or out of access scope");
|
plugins.beautylog.warn("function not existent or out of access scope");
|
||||||
};
|
};
|
||||||
|
});
|
||||||
|
this.socket.on("functionResponse", (dataArg:ISocketFunctionRequestObject) => {
|
||||||
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
done.reject("socket needs to be authenticated first");
|
done.reject("socket needs to be authenticated first");
|
||||||
|
@ -14,6 +14,8 @@ export type TSocketRequestSide = "requesting" | "responding";
|
|||||||
export interface SocketRequestConstructorOptions {
|
export interface SocketRequestConstructorOptions {
|
||||||
side: TSocketRequestSide;
|
side: TSocketRequestSide;
|
||||||
shortid: string;
|
shortid: string;
|
||||||
|
requestData?: ISocketFunctionRequestObject;
|
||||||
|
responseData?:ISocketFunctionResponseObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
//export objects
|
//export objects
|
||||||
@ -25,19 +27,33 @@ export class SocketRequest {
|
|||||||
status: TSocketRequestStatus = "new";
|
status: TSocketRequestStatus = "new";
|
||||||
side: TSocketRequestSide;
|
side: TSocketRequestSide;
|
||||||
shortid: string;
|
shortid: string;
|
||||||
|
requestData: ISocketFunctionRequestObject;
|
||||||
|
responseData: ISocketFunctionResponseObject;
|
||||||
constructor(optionsArg: SocketRequestConstructorOptions) {
|
constructor(optionsArg: SocketRequestConstructorOptions) {
|
||||||
this.side = optionsArg.side;
|
this.side = optionsArg.side;
|
||||||
this.shortid = optionsArg.shortid;
|
this.shortid = optionsArg.shortid;
|
||||||
|
this.requestData = optionsArg.requestData;
|
||||||
|
this.responseData = optionsArg.responseData;
|
||||||
if(this.side === "requesting"){
|
if(this.side === "requesting"){
|
||||||
allRequestingSocketRequests.add(this);
|
allRequestingSocketRequests.add(this);
|
||||||
} else {
|
} else {
|
||||||
allRespondingSocketRequests.add(this);
|
allRespondingSocketRequests.add(this);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
respond(dataArg:ISocketFunctionResponseObject){
|
|
||||||
|
private _sendRequest(dataArg:ISocketFunctionRequestObject){
|
||||||
|
|
||||||
|
};
|
||||||
|
private _receiveRequest(dataArg:ISocketFunctionRequestObject){
|
||||||
|
|
||||||
|
};
|
||||||
|
private _sendResponse(dataArg:ISocketFunctionResponseObject){
|
||||||
|
|
||||||
}
|
}
|
||||||
private _dispatch(){ // note: dispatch is private as it will be fired from the constructor
|
private _receiveResponse(dataArg:ISocketFunctionResponseObject){
|
||||||
|
|
||||||
}
|
};
|
||||||
|
private _dispatch(dataArg:ISocketFunctionRequestObject){ // note: dispatch is private as it will be fired from the constructor
|
||||||
|
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user