Before PioSocket dropin replacement

This commit is contained in:
2020-07-01 01:25:41 +02:00
parent c70faf81e0
commit f5fa51bef5
2 changed files with 9 additions and 8 deletions
+7 -7
View File
@@ -1,5 +1,6 @@
import { RPCServer, RPCSocket } from './Index'
import { RPCExporter } from './src/Interfaces'
import { RPCInterface } from './src/Types'
// TL;DR
const echo = (text: string) => text
@@ -175,17 +176,16 @@ interface IMyImplementation {
getCallback: (callback:Function) => string
}
type MyIfc = {
MyRPCGroup1: {
echo: IMyImplementation['echo']
add: IMyImplementation['add']
getAsync: IMyImplementation['getAsync']
getCallback: IMyImplementation['getCallback']
type IfcGenerator<Name extends string, Interface, keys extends keyof Interface = keyof Interface> = {
[name in Name]: {
[key in keys] : Interface[key]
}
}
type MyIfc = IfcGenerator<"MyRPCGroup1", IMyImplementation>
class MyImplementation implements IMyImplementation, RPCExporter<MyIfc>{
//"X" as "X" syntax is required to satisfy the type system (as it assumed string)
//"X" as "X" syntax is required to satisfy the type system (as it assumes string)
name = "MyRpcGroup11" as "MyRPCGroup1"
//List the functions you declared in MyIfc
+2 -1
View File
@@ -38,7 +38,8 @@ function makeServer() {
function triggerCallback(...messages: any[]): number { return subcallback.apply({}, messages) },
]
}], {
connectionHandler: (socket) => { },
connectionHandler: (socket) => {
},
closeHandler: (socket) => { },
errorHandler: (socket, err) => { throw err }
})