import { RPCServer } from '../src/Backend' import { SubscriptionResponse } from '../src/Responses' let subcallback new RPCServer(20000, [{ name: "HelloWorldRPCGroup", exportRPCs: () => [{ type: 'Call', name: 'echo', call: async (s:string) => s, }, { type: 'Hook', name: 'subscribe', hook: async (callback):Promise => { subcallback = callback return new SubscriptionResponse(""+Math.random()) }, unhook: async (uid):Promise => { subcallback = null } }, function add(...args:number[]):number {return args.reduce((a,b)=>a+b, 0)}, function triggerCallback(message):number {return subcallback(message)}, ] }]) try{ new RPCServer(20001, [{ name: "bad", exportRPCs: () => [ (aaa,bbb,ccc) => { return aaa+bbb+ccc } ] }]) }catch(badRPCError){ console.log("expected bad-RPC error happened: "+ !!badRPCError) }