2017-07-07 22:02:19 +02:00
|
|
|
import { Objectmap } from 'lik';
|
|
|
|
import { SocketRole } from './smartsocket.classes.socketrole';
|
2016-08-09 23:37:25 +02:00
|
|
|
/**
|
|
|
|
* interface of the contructor options of class SocketFunction
|
|
|
|
*/
|
2016-08-12 05:56:40 +02:00
|
|
|
export interface ISocketFunctionConstructorOptions {
|
2016-08-09 23:37:25 +02:00
|
|
|
funcName: string;
|
|
|
|
funcDef: any;
|
|
|
|
allowedRoles: SocketRole[];
|
2016-08-09 11:42:21 +02:00
|
|
|
}
|
2016-08-09 23:37:25 +02:00
|
|
|
/**
|
2016-08-12 05:56:40 +02:00
|
|
|
* interface of the Socket Function call, in other words the object that routes a call to a function
|
2016-08-09 23:37:25 +02:00
|
|
|
*/
|
|
|
|
export interface ISocketFunctionCall {
|
|
|
|
funcName: string;
|
|
|
|
funcDataArg: any;
|
2016-08-07 18:59:39 +02:00
|
|
|
}
|
2016-08-12 05:56:40 +02:00
|
|
|
/**
|
|
|
|
* interface for function definition of SocketFunction
|
|
|
|
*/
|
|
|
|
export interface IFuncDef {
|
|
|
|
(dataArg: any): PromiseLike<any>;
|
|
|
|
}
|
|
|
|
export declare let allSocketFunctions: Objectmap<SocketFunction>;
|
2016-08-09 11:42:21 +02:00
|
|
|
/**
|
2016-08-09 23:37:25 +02:00
|
|
|
* class that respresents a function that can be transparently called using a SocketConnection
|
2016-08-09 11:42:21 +02:00
|
|
|
*/
|
2016-08-07 18:59:39 +02:00
|
|
|
export declare class SocketFunction {
|
|
|
|
name: string;
|
2016-08-12 05:56:40 +02:00
|
|
|
funcDef: IFuncDef;
|
2016-08-07 18:59:39 +02:00
|
|
|
roles: SocketRole[];
|
2016-08-09 11:42:21 +02:00
|
|
|
/**
|
|
|
|
* the constructor for SocketFunction
|
|
|
|
*/
|
2016-08-12 05:56:40 +02:00
|
|
|
constructor(optionsArg: ISocketFunctionConstructorOptions);
|
2016-08-09 11:42:21 +02:00
|
|
|
/**
|
2017-07-07 22:02:19 +02:00
|
|
|
* invokes the function of this SocketFunction
|
2016-08-09 11:42:21 +02:00
|
|
|
*/
|
2017-07-07 22:02:19 +02:00
|
|
|
invoke(dataArg: ISocketFunctionCall): Promise<any>;
|
2016-08-09 11:42:21 +02:00
|
|
|
/**
|
2017-07-07 22:02:19 +02:00
|
|
|
* notifies a role about access to this SocketFunction
|
2016-08-09 11:42:21 +02:00
|
|
|
*/
|
2017-07-07 22:02:19 +02:00
|
|
|
private _notifyRole(socketRoleArg);
|
2016-08-07 18:59:39 +02:00
|
|
|
}
|