updated tests. Data now flows correctly between socket endpoints

This commit is contained in:
2016-08-15 01:38:28 +02:00
parent 24310b6709
commit 7f0fff0bf4
13 changed files with 107 additions and 32 deletions

View File

@@ -47,6 +47,7 @@ export class SocketRequest {
this.side = optionsArg.side;
this.shortid = optionsArg.shortId;
this.funcCallData = optionsArg.funcCallData;
this.originSocketConnection = optionsArg.originSocketConnection;
allSocketRequests.add(this);
};
@@ -68,7 +69,8 @@ export class SocketRequest {
* handles the response that is received by the requesting side
*/
handleResponse(responseDataArg: ISocketRequestDataObject) {
this.done.resolve(responseDataArg);
plugins.beautylog.log("handling response!");
this.done.resolve(responseDataArg.funcCallData);
allSocketRequests.remove(this);
}
@@ -79,12 +81,14 @@ export class SocketRequest {
*/
createResponse() {
let targetSocketFunction: SocketFunction = helpers.getSocketFunctionByName(this.funcCallData.funcName);
plugins.beautylog.info(`invoking ${targetSocketFunction.name}`);
targetSocketFunction.invoke(this.funcCallData)
.then((resultData) => {
plugins.beautylog.log("got resultData. Sending it to requesting party.")
let requestData: ISocketRequestDataObject = {
funcCallData: resultData,
shortId: this.shortid
}
};
this.originSocketConnection.socket.emit("functionResponse",requestData);
allSocketRequests.remove(this);
});