2016-08-09 09:42:21 +00:00
|
|
|
"use strict";
|
2016-08-09 21:37:25 +00:00
|
|
|
const plugins = require("./smartsocket.plugins");
|
2016-08-09 09:42:21 +00:00
|
|
|
// import classes
|
|
|
|
const lik_1 = require("lik");
|
|
|
|
;
|
2016-08-09 21:37:25 +00:00
|
|
|
;
|
2016-08-09 09:42:21 +00:00
|
|
|
//export objects
|
|
|
|
exports.allRequestingSocketRequests = new lik_1.Objectmap();
|
|
|
|
exports.allRespondingSocketRequests = new lik_1.Objectmap();
|
|
|
|
// export classes
|
|
|
|
class SocketRequest {
|
|
|
|
constructor(optionsArg) {
|
|
|
|
this.status = "new";
|
2016-08-09 21:37:25 +00:00
|
|
|
this.done = plugins.q.defer();
|
2016-08-09 09:42:21 +00:00
|
|
|
this.side = optionsArg.side;
|
2016-08-09 21:37:25 +00:00
|
|
|
this.shortid = optionsArg.shortId;
|
2016-08-09 09:42:21 +00:00
|
|
|
if (this.side === "requesting") {
|
|
|
|
exports.allRequestingSocketRequests.add(this);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
exports.allRespondingSocketRequests.add(this);
|
|
|
|
}
|
|
|
|
;
|
2016-08-09 21:37:25 +00:00
|
|
|
// build request and response dataArg
|
|
|
|
this.requestData = {
|
|
|
|
funcCallData: optionsArg.funcCallData,
|
|
|
|
shortId: optionsArg.shortId
|
|
|
|
};
|
2016-08-09 09:42:21 +00:00
|
|
|
}
|
|
|
|
;
|
2016-08-09 21:37:25 +00:00
|
|
|
dispatch() {
|
|
|
|
this.originSocketConnection.socket.emit("function", this.requestData);
|
|
|
|
return this.done.promise;
|
2016-08-09 14:33:56 +00:00
|
|
|
}
|
|
|
|
;
|
2016-08-09 21:37:25 +00:00
|
|
|
handleResponse(responseDataArg) {
|
|
|
|
this.done.resolve(responseDataArg);
|
2016-08-09 14:33:56 +00:00
|
|
|
}
|
2016-08-09 21:37:25 +00:00
|
|
|
respond(dataArg) {
|
2016-08-09 14:33:56 +00:00
|
|
|
}
|
|
|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