test
This commit is contained in:
+8
-2
@@ -9,7 +9,8 @@ import * as I from './Interfaces';
|
||||
|
||||
export class RPCServer<
|
||||
SubResType = {}
|
||||
>{
|
||||
> implements I.Destroyable{
|
||||
|
||||
private ws = http.createServer()
|
||||
private io = bsock.createServer()
|
||||
private visibility:T.Visibility
|
||||
@@ -34,7 +35,7 @@ export class RPCServer<
|
||||
|
||||
if(!conf.closeHandler) this.closeHandler =
|
||||
(socket:I.Socket) => () => {
|
||||
console.log("Socket on port "+socket.port+"closing")
|
||||
console.log("Socket on port "+socket.port+" closing")
|
||||
}
|
||||
|
||||
if(!conf.connectionHandler) this.connectionHandler =
|
||||
@@ -78,4 +79,9 @@ export class RPCServer<
|
||||
...this.exporters.flatMap(exporter => U.rpcHooker(socket, exporter))
|
||||
]
|
||||
}
|
||||
|
||||
async destroy(): Promise<void> {
|
||||
this.io.close()
|
||||
this.ws.close()
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,7 @@ export class RPCSocket implements I.Socket{
|
||||
|
||||
public async connect(){
|
||||
this.socket = await bsock.connect(this.port, this.server, this.tls)
|
||||
this.on('error', () => {})
|
||||
|
||||
const info:T.ExtendedRpcInfo[] = await this.info()
|
||||
info.forEach(i => {
|
||||
|
||||
+7
-4
@@ -6,13 +6,16 @@ export interface Exporter<T = {}>{
|
||||
exportRPCs() : T.RPC<T>[]
|
||||
}
|
||||
|
||||
export interface Socket {
|
||||
export interface Socket extends Destroyable {
|
||||
port: number
|
||||
hook: (rpcname: T.Name, ...args: T.Any[]) => I.Socket
|
||||
unhook: (rpcname:T.Name) => I.Socket
|
||||
call: (rpcname:T.Name, ...args: T.Any[]) => Promise<T.Any>
|
||||
fire: (rpcname:T.Name, ...args: T.Any[]) => Promise<T.Any>
|
||||
on: T.OnFunction
|
||||
destroy: ()=>void
|
||||
close: ()=>void
|
||||
on: T.OnFunction
|
||||
close() : void
|
||||
}
|
||||
|
||||
export interface Destroyable{
|
||||
destroy() : void
|
||||
}
|
||||
Reference in New Issue
Block a user