now working in both directions so mesh setups work.

This commit is contained in:
Philipp Kunz 2016-08-15 02:36:17 +02:00
parent 180ae23c9a
commit 84f33fa447
13 changed files with 129 additions and 20 deletions

1
dist/index.d.ts vendored
View File

@ -2,3 +2,4 @@ export * from "./smartsocket.classes.smartsocket";
export * from "./smartsocket.classes.smartsocketclient"; export * from "./smartsocket.classes.smartsocketclient";
export * from "./smartsocket.classes.socketfunction"; export * from "./smartsocket.classes.socketfunction";
export * from "./smartsocket.classes.socketrole"; export * from "./smartsocket.classes.socketrole";
export { allSocketConnections } from "./smartsocket.classes.socketconnection";

6
dist/index.js vendored
View File

@ -2,9 +2,13 @@
function __export(m) { function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
} }
// export main classes
__export(require("./smartsocket.classes.smartsocket")); __export(require("./smartsocket.classes.smartsocket"));
__export(require("./smartsocket.classes.smartsocketclient")); __export(require("./smartsocket.classes.smartsocketclient"));
// export further classes and objects
__export(require("./smartsocket.classes.socketfunction")); __export(require("./smartsocket.classes.socketfunction"));
__export(require("./smartsocket.classes.socketrole")); __export(require("./smartsocket.classes.socketrole"));
var smartsocket_classes_socketconnection_1 = require("./smartsocket.classes.socketconnection");
exports.allSocketConnections = smartsocket_classes_socketconnection_1.allSocketConnections;
// need something more exposed? Create an issue on GitLab! // need something more exposed? Create an issue on GitLab!
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsaUJBQWMsbUNBQW1DLENBQUMsRUFBQTtBQUNsRCxpQkFBYyx5Q0FBeUMsQ0FBQyxFQUFBO0FBQ3hELGlCQUFjLHNDQUFzQyxDQUFDLEVBQUE7QUFDckQsaUJBQWMsa0NBQWtDLENBQUMsRUFBQTtBQUVqRCwwREFBMEQifQ== //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsc0JBQXNCO0FBQ3RCLGlCQUFjLG1DQUFtQyxDQUFDLEVBQUE7QUFDbEQsaUJBQWMseUNBQXlDLENBQUMsRUFBQTtBQUV4RCxxQ0FBcUM7QUFDckMsaUJBQWMsc0NBQXNDLENBQUMsRUFBQTtBQUNyRCxpQkFBYyxrQ0FBa0MsQ0FBQyxFQUFBO0FBQ2pELHFEQUFtQyx3Q0FBd0MsQ0FBQztBQUFwRSwyRkFBb0U7QUFFNUUsMERBQTBEIn0=

View File

@ -1,4 +1,6 @@
/// <reference types="socket.io" /> /// <reference types="socket.io" />
/// <reference types="q" />
import * as plugins from "./smartsocket.plugins";
import { Objectmap } from "lik"; import { Objectmap } from "lik";
import { SocketConnection } from "./smartsocket.classes.socketconnection"; import { SocketConnection } from "./smartsocket.classes.socketconnection";
export interface ISmartsocketConstructorOptions { export interface ISmartsocketConstructorOptions {
@ -18,5 +20,8 @@ export declare class Smartsocket {
*/ */
startServer: () => void; startServer: () => void;
closeServer: () => void; closeServer: () => void;
clientCall(): void; /**
* allows call to specific client.
*/
clientCall(functionNameArg: string, dataArg: any, targetSocketConnectionArg: SocketConnection): plugins.q.Promise<{}>;
} }

View File

@ -3,6 +3,7 @@ const plugins = require("./smartsocket.plugins");
// classes // classes
const lik_1 = require("lik"); const lik_1 = require("lik");
const smartsocket_classes_socketconnection_1 = require("./smartsocket.classes.socketconnection"); const smartsocket_classes_socketconnection_1 = require("./smartsocket.classes.socketconnection");
const smartsocket_classes_socketrequest_1 = require("./smartsocket.classes.socketrequest");
; ;
class Smartsocket { class Smartsocket {
constructor(optionsArg) { constructor(optionsArg) {
@ -35,6 +36,7 @@ class Smartsocket {
alias: undefined, alias: undefined,
authenticated: false, authenticated: false,
role: undefined, role: undefined,
side: "server",
socket: socketArg socket: socketArg
}); });
plugins.beautylog.log("Socket connected. Trying to authenticate..."); plugins.beautylog.log("Socket connected. Trying to authenticate...");
@ -49,9 +51,26 @@ class Smartsocket {
} }
; ;
// communication // communication
clientCall() { /**
// TODO: target specific client and initiate response * allows call to specific client.
*/
clientCall(functionNameArg, dataArg, targetSocketConnectionArg) {
let done = plugins.q.defer();
let socketRequest = new smartsocket_classes_socketrequest_1.SocketRequest({
side: "requesting",
originSocketConnection: targetSocketConnectionArg,
shortId: plugins.shortid.generate(),
funcCallData: {
funcName: functionNameArg,
funcDataArg: dataArg
}
});
socketRequest.dispatch()
.then((dataArg) => {
done.resolve(dataArg.funcDataArg);
});
return done.promise;
} }
} }
exports.Smartsocket = Smartsocket; exports.Smartsocket = Smartsocket;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zbWFydHNvY2tldC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmNsYXNzZXMuc21hcnRzb2NrZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHVCQUF1QixDQUFDLENBQUE7QUFHakQsVUFBVTtBQUNWLHNCQUEwQixLQUFLLENBQUMsQ0FBQTtBQUdoQyx1REFBaUMsd0NBQXdDLENBQUMsQ0FBQTtBQUt6RSxDQUFDO0FBRUY7SUFJSSxZQUFZLFVBQTBDO1FBRHRELGdCQUFXLEdBQUcsSUFBSSxlQUFTLEVBQW9CLENBQUM7UUEwQmhEOztXQUVHO1FBRUgsZ0JBQVcsR0FBRztZQUNWLElBQUksQ0FBQyxFQUFFLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDL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UFJLENBQUM7WUFDRixNQUFNLENBQUMsZ0JBQWdCLENBQUMsd0JBQXdCLEVBQUUsQ0FBQztRQUN2RCxDQUFDLENBQUM7YUFDRCxLQUFLLENBQUMsQ0FBQyxHQUFHO1lBQ1AsT0FBTyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQztRQUNyQixDQUFDLENBQUMsQ0FBQztJQUNYLENBQUM7O0lBcUJELGdCQUFnQjtJQUVoQjs7T0FFRztJQUNILFVBQVUsQ0FBQyxlQUFzQixFQUFDLE9BQVcsRUFBQyx5QkFBMEM7UUFDcEYsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUM3QixJQUFJLGFBQWEsR0FBRyxJQUFJLGlEQUFhLENBQUM7WUFDbEMsSUFBSSxFQUFDLFlBQVk7WUFDakIsc0JBQXNCLEVBQUMseUJBQXlCO1lBQ2hELE9BQU8sRUFBQyxPQUFPLENBQUMsT0FBTyxDQUFDLFFBQVEsRUFBRTtZQUNsQyxZQUFZLEVBQUM7Z0JBQ1QsUUFBUSxFQUFFLGVBQWU7Z0JBQ3pCLFdBQVcsRUFBQyxPQUFPO2FBQ3RCO1NBQ0osQ0FBQyxDQUFDO1FBQ0gsYUFBYSxDQUFDLFFBQVEsRUFBRTthQUNuQixJQUFJLENBQUMsQ0FBQyxPQUEyQjtZQUM5QixJQUFJLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztRQUN0QyxDQUFDLENBQUMsQ0FBQztRQUNQLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7QUFDTCxDQUFDO0FBdkVZLG1CQUFXLGNBdUV2QixDQUFBIn0=

View File

@ -23,6 +23,7 @@ class SmartsocketClient {
alias: this.alias, alias: this.alias,
authenticated: false, authenticated: false,
role: undefined, role: undefined,
side: "client",
socket: plugins.socketIoClient(socketUrl, { multiplex: false }) socket: plugins.socketIoClient(socketUrl, { multiplex: false })
}); });
this.socketConnection.socket.on("requestAuth", () => { this.socketConnection.socket.on("requestAuth", () => {
@ -70,4 +71,4 @@ class SmartsocketClient {
; ;
} }
exports.SmartsocketClient = SmartsocketClient; exports.SmartsocketClient = SmartsocketClient;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zbWFydHNvY2tldGNsaWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c29ja2V0LmNsYXNzZXMuc21hcnRzb2NrZXRjbGllbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHVCQUl6QixDQUFDLENBSitDO0FBT2hELGlCQUFpQjtBQUNqQix1REFBaUMsd0NBQXdDLENBQUMsQ0FBQTtBQUUxRSxvREFBOEIscUNBQXFDLENBQUMsQ0FBQTtBQVlwRTtJQU9JLFlBQVksVUFBb0M7UUFDNUMsSUFBSSxDQUFDLEtBQUssR0FBRyxVQUFVLENBQUMsS0FBSyxDQUFDO1FBQzlCLElBQUksQ0FBQyxJQUFJLEdBQUcsVUFBVSxDQUFDLElBQUksQ0FBQztRQUM1QixJQUFJLENBQUMsU0FBUyxHQUFHLFVBQVUsQ0FBQyxHQUFHLENBQUE7UUFDL0IsSUFBSSxDQUFDLFVBQVUsR0FBRyxVQUFVLENBQUMsSUFBSSxDQUFDO1FBQ2xDLElBQUksQ0FBQyxjQUFjLEdBQUcsVUFBVSxDQUFDLFFBQVEsQ0FBQTtJQUM3QyxDQUFDOztJQUVEOztPQUVHO0lBQ0gsT0FBTztRQUNILElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDN0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsc0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QyxXQUFXLENBQUMsQ0FBQztRQUN0QyxDQUFDLENBQUMsQ0FBQztRQUNQLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0lBQ3hCLENBQUM7O0FBRUwsQ0FBQztBQXZFWSx5QkFBaUIsb0JBdUU3QixDQUFBIn0=

View File

@ -2,7 +2,12 @@
/// <reference types="socket.io-client" /> /// <reference types="socket.io-client" />
/// <reference types="q" /> /// <reference types="q" />
import * as plugins from "./smartsocket.plugins"; import * as plugins from "./smartsocket.plugins";
import { Objectmap } from "lik";
import { SocketRole } from "./smartsocket.classes.socketrole"; import { SocketRole } from "./smartsocket.classes.socketrole";
/**
* defines is a SocketConnection is server or client side. Important for mesh setups.
*/
export declare type TSocketConnectionSide = "server" | "client";
/** /**
* interface for constructor of class SocketConnection * interface for constructor of class SocketConnection
*/ */
@ -10,6 +15,7 @@ export interface ISocketConnectionConstructorOptions {
alias: string; alias: string;
authenticated: boolean; authenticated: boolean;
role: SocketRole; role: SocketRole;
side: TSocketConnectionSide;
socket: SocketIO.Socket | SocketIOClient.Socket; socket: SocketIO.Socket | SocketIOClient.Socket;
} }
/** /**
@ -20,11 +26,13 @@ export interface ISocketConnectionAuthenticationObject {
password: "somePassword"; password: "somePassword";
alias: "coreflow1"; alias: "coreflow1";
} }
export declare let allSocketConnections: Objectmap<SocketConnection>;
/** /**
* class SocketConnection represents a websocket connection * class SocketConnection represents a websocket connection
*/ */
export declare class SocketConnection { export declare class SocketConnection {
alias: string; alias: string;
side: TSocketConnectionSide;
authenticated: boolean; authenticated: boolean;
role: SocketRole; role: SocketRole;
socket: SocketIO.Socket | SocketIOClient.Socket; socket: SocketIO.Socket | SocketIOClient.Socket;

View File

@ -1,9 +1,12 @@
"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 lik_1 = require("lik");
const smartsocket_classes_socketrequest_1 = require("./smartsocket.classes.socketrequest"); const smartsocket_classes_socketrequest_1 = require("./smartsocket.classes.socketrequest");
; ;
;
// export classes // export classes
exports.allSocketConnections = new lik_1.Objectmap();
/** /**
* class SocketConnection represents a websocket connection * class SocketConnection represents a websocket connection
*/ */
@ -13,10 +16,13 @@ class SocketConnection {
this.alias = optionsArg.alias; this.alias = optionsArg.alias;
this.authenticated = optionsArg.authenticated; this.authenticated = optionsArg.authenticated;
this.role = optionsArg.role; this.role = optionsArg.role;
this.side = optionsArg.side;
this.socket = optionsArg.socket; this.socket = optionsArg.socket;
// standard behaviour that is always true // standard behaviour that is always true
exports.allSocketConnections.add(this);
this.socket.on("disconnect", () => { this.socket.on("disconnect", () => {
plugins.beautylog.info(`Client ${this.alias} disconnected`); plugins.beautylog.info(`SocketConnection with >alias ${this.alias} on >side ${this.side} disconnected`);
exports.allSocketConnections.remove(this);
}); });
} }
; ;
@ -96,4 +102,4 @@ class SocketConnection {
} }
exports.SocketConnection = SocketConnection; exports.SocketConnection = SocketConnection;
; ;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRjb25uZWN0aW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzb2NrZXQuY2xhc3Nlcy5zb2NrZXRjb25uZWN0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSx1QkFBdUIsQ0FBQyxDQUFBO0FBQ2pELE1BQVksT0FBTyxXQUFNLHVCQUF1QixDQUFDLENBQUE7QUFJakQsb0RBQTJFLHFDQUFxQyxDQUFDLENBQUE7QUFhaEgsQ0FBQztBQVdGLGlCQUFpQjtBQUVqQjs7R0FFRztBQUNIO0lBS0ksWUFBWSxVQUErQztRQUgzRCxrQkFBYSxHQUFZLEtBQUssQ0FBQztRQUkzQixJQUFJLENBQUMsS0FBSyxHQUF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should connect in parallel", function () { it("2 clients should connect in parallel", function () {
}); });
it("should be able to make a functionCall", function (done) { it("should be able to make a functionCall from client to server", function (done) {
this.timeout(5000); this.timeout(5000);
testSmartsocketClient.serverCall("testFunction1", { testSmartsocketClient.serverCall("testFunction1", {
value1: "hello" value1: "hello"
@ -80,6 +80,20 @@ describe("smartsocket", function () {
done(); done();
}); });
}); });
it("should be able to make a functionCall from server to client", function (done) {
this.timeout(5000);
let targetSocket = (() => {
return smartsocket.allSocketConnections.find((socketConnectionArg) => {
return socketConnectionArg.alias === "testClient1";
});
})();
testSmartsocket.clientCall("testFunction1", {
value1: "helloFromServer"
}, targetSocket).then((dataArg) => {
console.log(dataArg);
done();
});
});
}); });
describe("terminating smartsocket", function () { describe("terminating smartsocket", function () {
it("should close the server", function () { it("should close the server", function () {
@ -87,4 +101,4 @@ describe("smartsocket", function () {
}); });
}); });
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUVoQixNQUFPLFdBQVcsV0FBVyxlQUFlLENBQUMsQ0FBQztBQUM5QyxNQUFPLENBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUV4QixJQUFJLGVBQXdDLENBQUM7QUFDN0MsSUFBSSxxQkFBb0QsQ0FBQztBQUN6RCxJQUFJLGVBQXVDLENBQUM7QUFDNUMsSUFBSSxtQkFBOEMsQ0FBQztBQUVuRCxJQUFJLFVBQVUsR0FBRztJQUNiLElBQUksRUFBRSxJQUFJO0NBQ2IsQ0FBQTtBQUVELFFBQVEsQ0FBQyxhQUFhLEVBQUU7SUFDcEIsUUFBUSxDQUFDLG1CQUFtQixFQUFFO1FBQzFCLEVBQUUsQ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LQUFLLEtBQUssYUFBYSxDQUFDO2dCQUN2RCxDQUFDLENBQUMsQ0FBQztZQUNQLENBQUMsQ0FBQyxFQUFFLENBQUM7WUFDTCxlQUFlLENBQUMsVUFBVSxDQUFDLGVBQWUsRUFBQztnQkFDdkMsTUFBTSxFQUFDLGlCQUFpQjthQUMzQixFQUFDLFlBQVksQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLE9BQU87Z0JBQ3pCLE9BQU8sQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLENBQUM7Z0JBQ3JCLElBQUksRUFBRSxDQUFDO1lBQ1gsQ0FBQyxDQUFDLENBQUM7UUFDUCxDQUFDLENBQUMsQ0FBQztJQUVQLENBQUMsQ0FBQyxDQUFDO0lBQ0gsUUFBUSxDQUFDLHlCQUF5QixFQUFFO1FBQ2hDLEVBQUUsQ0FBQyx5QkFBeUIsRUFBRTtZQUMxQixlQUFlLENBQUMsV0FBVyxFQUFFLENBQUM7UUFDbEMsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQyxDQUFDIn0=

View File

@ -75,7 +75,7 @@ describe("smartsocket", function () {
it("2 clients should connect in parallel", function () { it("2 clients should connect in parallel", function () {
}); });
it("should be able to make a functionCall",function(done){ it("should be able to make a functionCall from client to server",function(done){
this.timeout(5000); this.timeout(5000);
testSmartsocketClient.serverCall("testFunction1",{ testSmartsocketClient.serverCall("testFunction1",{
value1:"hello" value1:"hello"
@ -83,7 +83,22 @@ describe("smartsocket", function () {
console.log(dataArg); console.log(dataArg);
done(); done();
}); });
}) });
it("should be able to make a functionCall from server to client",function(done){
this.timeout(5000);
let targetSocket = (() => {
return smartsocket.allSocketConnections.find((socketConnectionArg)=>{
return socketConnectionArg.alias === "testClient1";
});
})();
testSmartsocket.clientCall("testFunction1",{
value1:"helloFromServer"
},targetSocket).then((dataArg) => {
console.log(dataArg);
done();
});
});
}); });
describe("terminating smartsocket", function () { describe("terminating smartsocket", function () {
it("should close the server", function () { it("should close the server", function () {

View File

@ -1,8 +1,12 @@
import * as plugins from "./smartsocket.plugins"; import * as plugins from "./smartsocket.plugins";
// export main classes
export * from "./smartsocket.classes.smartsocket"; export * from "./smartsocket.classes.smartsocket";
export * from "./smartsocket.classes.smartsocketclient"; export * from "./smartsocket.classes.smartsocketclient";
// export further classes and objects
export * from "./smartsocket.classes.socketfunction"; export * from "./smartsocket.classes.socketfunction";
export * from "./smartsocket.classes.socketrole"; export * from "./smartsocket.classes.socketrole";
export {allSocketConnections} from "./smartsocket.classes.socketconnection";
// need something more exposed? Create an issue on GitLab! // need something more exposed? Create an issue on GitLab!

View File

@ -3,13 +3,13 @@ import * as helpers from "./smartsocket.helpers";
// classes // classes
import { Objectmap } from "lik"; import { Objectmap } from "lik";
import { SocketRole } from "./smartsocket.classes.socketrole"; import { SocketFunction,ISocketFunctionCall} from "./smartsocket.classes.socketfunction";
import { SocketFunction } from "./smartsocket.classes.socketfunction";
import { SocketConnection } from "./smartsocket.classes.socketconnection"; import { SocketConnection } from "./smartsocket.classes.socketconnection";
import { SocketRequest } from "./smartsocket.classes.socketrequest";
import { SocketRole } from "./smartsocket.classes.socketrole";
export interface ISmartsocketConstructorOptions { export interface ISmartsocketConstructorOptions {
port: number; port: number;
}; };
export class Smartsocket { export class Smartsocket {
@ -28,6 +28,7 @@ export class Smartsocket {
alias:undefined, alias:undefined,
authenticated:false, authenticated:false,
role:undefined, role:undefined,
side:"server",
socket:socketArg socket:socketArg
}); });
plugins.beautylog.log("Socket connected. Trying to authenticate...") plugins.beautylog.log("Socket connected. Trying to authenticate...")
@ -61,8 +62,25 @@ export class Smartsocket {
}; };
// communication // communication
clientCall(){
/**
// TODO: target specific client and initiate response * allows call to specific client.
*/
clientCall(functionNameArg:string,dataArg:any,targetSocketConnectionArg:SocketConnection){
let done = plugins.q.defer();
let socketRequest = new SocketRequest({
side:"requesting",
originSocketConnection:targetSocketConnectionArg,
shortId:plugins.shortid.generate(),
funcCallData:{
funcName: functionNameArg,
funcDataArg:dataArg
}
});
socketRequest.dispatch()
.then((dataArg:ISocketFunctionCall) => {
done.resolve(dataArg.funcDataArg);
});
return done.promise;
} }
} }

View File

@ -46,6 +46,7 @@ export class SmartsocketClient {
alias:this.alias, alias:this.alias,
authenticated:false, authenticated:false,
role:undefined, role:undefined,
side:"client",
socket: plugins.socketIoClient(socketUrl,{multiplex:false}) socket: plugins.socketIoClient(socketUrl,{multiplex:false})
}); });
this.socketConnection.socket.on("requestAuth", () => { this.socketConnection.socket.on("requestAuth", () => {

View File

@ -1,6 +1,8 @@
import * as plugins from "./smartsocket.plugins"; import * as plugins from "./smartsocket.plugins";
import * as helpers from "./smartsocket.helpers"; import * as helpers from "./smartsocket.helpers";
import {Objectmap} from "lik";
// import classes // import classes
import { SocketFunction } from "./smartsocket.classes.socketfunction"; import { SocketFunction } from "./smartsocket.classes.socketfunction";
import { SocketRequest, ISocketRequestDataObject, allSocketRequests } from "./smartsocket.classes.socketrequest"; import { SocketRequest, ISocketRequestDataObject, allSocketRequests } from "./smartsocket.classes.socketrequest";
@ -8,6 +10,11 @@ import { SocketRole } from "./smartsocket.classes.socketrole";
// export interfaces // export interfaces
/**
* defines is a SocketConnection is server or client side. Important for mesh setups.
*/
export type TSocketConnectionSide = "server" | "client";
/** /**
* interface for constructor of class SocketConnection * interface for constructor of class SocketConnection
*/ */
@ -15,6 +22,7 @@ export interface ISocketConnectionConstructorOptions {
alias: string; alias: string;
authenticated: boolean; authenticated: boolean;
role: SocketRole; role: SocketRole;
side: TSocketConnectionSide;
socket: SocketIO.Socket | SocketIOClient.Socket; socket: SocketIO.Socket | SocketIOClient.Socket;
}; };
@ -25,15 +33,17 @@ export interface ISocketConnectionAuthenticationObject {
role: "coreflowContainer", role: "coreflowContainer",
password: "somePassword", password: "somePassword",
alias: "coreflow1" alias: "coreflow1"
} };
// export classes // export classes
export let allSocketConnections = new Objectmap<SocketConnection>();
/** /**
* class SocketConnection represents a websocket connection * class SocketConnection represents a websocket connection
*/ */
export class SocketConnection { export class SocketConnection {
alias: string; alias: string;
side:TSocketConnectionSide;
authenticated: boolean = false; authenticated: boolean = false;
role: SocketRole; role: SocketRole;
socket: SocketIO.Socket | SocketIOClient.Socket; socket: SocketIO.Socket | SocketIOClient.Socket;
@ -41,11 +51,14 @@ export class SocketConnection {
this.alias = optionsArg.alias; this.alias = optionsArg.alias;
this.authenticated = optionsArg.authenticated; this.authenticated = optionsArg.authenticated;
this.role = optionsArg.role; this.role = optionsArg.role;
this.side = optionsArg.side;
this.socket = optionsArg.socket; this.socket = optionsArg.socket;
// standard behaviour that is always true // standard behaviour that is always true
allSocketConnections.add(this);
this.socket.on("disconnect", () => { this.socket.on("disconnect", () => {
plugins.beautylog.info(`Client ${this.alias} disconnected`); plugins.beautylog.info(`SocketConnection with >alias ${this.alias} on >side ${this.side} disconnected`);
allSocketConnections.remove(this);
}); });
}; };