This commit is contained in:
2019-09-22 10:29:26 +02:00
parent 3dadc48b32
commit 887e51392d
2 changed files with 17 additions and 9 deletions
+6
View File
@@ -50,6 +50,12 @@ RPC did not provide a name.
throw new Error("Bad socketIORPC type "+ typeof rpc)
}
/**
* Utility function to apply the RPCs of an {@link Exporter}.
* @param socket The websocket (implementation: bsock) to hook on
* @param exporter The exporter
* @param makeUnique @default true Attach a suffix to RPC names
*/
export function rpcHooker<SubResT = {}>(socket: I.Socket, exporter:I.Exporter<SubResT>, makeUnique = true):T.ExtendedRpcInfo[]{
const owner = exporter.name
const RPCs = [...exporter.exportRPCs()]