update structure
This commit is contained in:
parent
0bde7ec41b
commit
d005ceff58
@ -9,7 +9,6 @@ We recommend the use of typescript.
|
||||
|
||||
### Serverside
|
||||
```typescript
|
||||
|
||||
import * as smartsocket from "smartsocket";
|
||||
|
||||
let mySmartsocket = new smartsocket.Smartsocket({
|
||||
|
@ -3,6 +3,9 @@ import * as helpers from "./smartsocket.helpers";
|
||||
|
||||
// classes
|
||||
import { Objectmap } from "lik";
|
||||
import {SocketRole} from "./smartsocket.classes.socketrole";
|
||||
import {SocketFunction} from "./smartsocket.classes.socketfunction";
|
||||
|
||||
|
||||
export interface ISocketObject {
|
||||
group?:string,
|
||||
@ -13,11 +16,12 @@ export interface ISocketObject {
|
||||
export interface ISmartsocketConstructorOptions {
|
||||
port: number;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
export class Smartsocket {
|
||||
io: SocketIO.Server;
|
||||
openSockets = new Objectmap();
|
||||
registeredRoles = new Objectmap();
|
||||
constructor(options: ISmartsocketConstructorOptions) {
|
||||
this.io = plugins.socketIo(options.port);
|
||||
this.io.on('connection', this._handleSocket);
|
||||
@ -36,9 +40,11 @@ export class Smartsocket {
|
||||
.then();
|
||||
}
|
||||
|
||||
registerGroup(string){
|
||||
|
||||
}
|
||||
registerRole(socketRoleArg:SocketRole){
|
||||
this.registeredRoles.add(socketRoleArg);
|
||||
};
|
||||
|
||||
|
||||
|
||||
closeServer = () => {
|
||||
this.io.close();
|
||||
|
23
ts/smartsocket.classes.socketfunction.ts
Normal file
23
ts/smartsocket.classes.socketfunction.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import * as plugins from "./smartsocket.plugins";
|
||||
|
||||
// import classes
|
||||
import { SocketRole } from "./smartsocket.classes.socketrole";
|
||||
|
||||
|
||||
|
||||
export interface SocketFunctionOptions {
|
||||
name: string;
|
||||
func: any;
|
||||
roles: SocketRole[]; // all roles that are allowed to execute a SocketFunction
|
||||
};
|
||||
|
||||
export class SocketFunction {
|
||||
name: string;
|
||||
func: any;
|
||||
roles: SocketRole[];
|
||||
constructor(optionsArg: SocketFunctionOptions) {
|
||||
this.name = optionsArg.name;
|
||||
this.func = optionsArg.func;
|
||||
this.roles = optionsArg.roles;
|
||||
};
|
||||
}
|
@ -1,10 +1,22 @@
|
||||
import * as plugins from "./smartsocket.plugins";
|
||||
|
||||
/**
|
||||
* interface for class SocketRole
|
||||
*/
|
||||
export interface SocketRoleOptions {
|
||||
name:string;
|
||||
passwordHash:string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A socketrole defines access to certain routines.
|
||||
*/
|
||||
class Role {
|
||||
constructor(){
|
||||
|
||||
export class SocketRole {
|
||||
name:string;
|
||||
passwordHash:string;
|
||||
constructor(optionsArg:SocketRoleOptions){
|
||||
this.name = optionsArg.name;
|
||||
this.passwordHash = optionsArg.passwordHash;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user