Before PioSocket dropin replacement
This commit is contained in:
@@ -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
@@ -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 }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user