Finish implementation of new Rust Tokio Target
This commit is contained in:
@ -1,18 +1,31 @@
|
||||
|
||||
import * as net from "net";
|
||||
import { Server, AddValueRequest, AddValueResponse } from "./out";
|
||||
import { Server, AddValueRequest, AddValueResponse, Test2 } from "./out";
|
||||
import * as readline from 'node:readline';
|
||||
|
||||
|
||||
const server = new Server.ServiceProvider();
|
||||
|
||||
class SimpleTestService extends Server.SimpleTestService<undefined> {
|
||||
async GetTest(name: string, age: number, ctx: undefined): Promise<Test2> {
|
||||
return {
|
||||
name,
|
||||
age,
|
||||
};
|
||||
}
|
||||
TestNot(ctx: undefined): void {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TestService extends Server.TestService<undefined> {
|
||||
async AddValuesSingleParam(
|
||||
request: AddValueRequest,
|
||||
ctx: undefined
|
||||
): Promise<AddValueResponse> {
|
||||
return {
|
||||
value: request.value1 + request!.value2,
|
||||
value: request.value1! + request!.value2!,
|
||||
};
|
||||
}
|
||||
async AddValuesMultipleParams(
|
||||
@ -41,6 +54,7 @@ class TestService extends Server.TestService<undefined> {
|
||||
}
|
||||
|
||||
server.addService(new TestService());
|
||||
server.addService(new SimpleTestService());
|
||||
|
||||
net.createServer((socket) => {
|
||||
socket.on("error", console.error);
|
||||
@ -57,6 +71,6 @@ net.createServer((socket) => {
|
||||
sess.onMessage(JSON.parse(line));
|
||||
})
|
||||
rl.on("error", console.error);
|
||||
}).listen(8859).on("listening", () => {
|
||||
console.log("Is listening on :8859");
|
||||
}).on("error", console.error)
|
||||
}).listen(4321).on("listening", () => {
|
||||
console.log("Is listening on :4321");
|
||||
}).on("error", console.error)
|
||||
|
Reference in New Issue
Block a user