This commit is contained in:
2019-09-21 14:31:40 +02:00
parent 67278ff2fe
commit ac9e6d3732
5 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "rpclibrary",
"version": "1.0.4",
"version": "1.1.0",
"description": "",
"main": "./js/Index.js",
"scripts": {
+1 -1
View File
@@ -46,7 +46,7 @@ export class RPCServer<
if(badRPC = exporters.flatMap(ex => ex.exportRPCs()).find(rpc => !rpc.name))
throw new Error(`
RPC did not provide a name.
\nUse funtion name(..){ .. } syntax instead.
\nUse 'funtion name(..){ .. }' syntax instead.
\n
\n<------------OFFENDING RPC:
\n`+badRPC.toString()+`
+4 -4
View File
@@ -48,7 +48,7 @@ export type BaseInfo = {
export type HookInfo<T = {}> = BaseInfo & {
type: 'Hook',
generator: (socket) => HookFunction<T>
generator: (socket?:I.Socket) => HookFunction<T>
}
export type CallInfo = BaseInfo & {
@@ -61,6 +61,6 @@ export type ExtendedRpcInfo = RpcInfo & { uniqueName: string }
export type OnFunction = (type: 'error' | 'close', f: (e?:any)=>void) => I.Socket
export type HookCloseFunction<T = {}> = (res:SubscriptionResponse<T>, rpc:HookRPC<T>) => any
export type HookFunction<T = {}> = (...args:[any, ...any[]]) => Promise<SubscriptionResponse<T> | ErrorResponse>
export type AsyncFunction = (...args:any[]) => Promise<any>
export type CallbackFunction = (...args:any[]) => void
export type HookFunction<T = {}> = (...args:any) => Promise<SubscriptionResponse<T> | ErrorResponse>
export type AsyncFunction = (...args:any) => Promise<any>
export type CallbackFunction = (...args:any) => void
+1 -1
View File
@@ -28,7 +28,7 @@ export const rpcToRpcinfo = <SubResT = {}>(rpc : T.RPC<SubResT>, owner: T.Owner)
case "function":
if(!rpc.name) throw new Error(`
RPC did not provide a name.
\nUse funtion name(..){ .. } syntax instead.
\nUse 'funtion name(..){ .. }' syntax instead.
\n
\n<------------OFFENDING RPC:
\n`+rpc.toString()+`
+3 -3
View File
@@ -24,18 +24,18 @@ new RPCServer(20000, [{
subcallback = callback
return makeSubResponse()
},
onClose: (res:SubscriptionResponse, rpc:HookRPC) => {
onClose: (res, rpc) => {
console.log("Specific close handler for", rpc.name, res)
subcallback = null
},
onCallback: (...args:any) => { console.log.apply(console, args) }
onCallback: (...args) => { console.log.apply(console, args) }
},
function add(...args:number[]):number {return args.reduce((a,b)=>a+b, 0)},
function triggerCallback(...messages:any[]):number {return subcallback.apply({}, messages)},
]
}])
new RPCServer<{ topic: string}>(20001, [{
new RPCServer<{ topic: string }>(20001, [{
name: "HelloWorldRPCGroup",
exportRPCs: () => [
{