1
0
mirror of synced 2025-02-12 00:53:01 +01:00
Bayshore/src/modules/startup.ts

69 lines
2.6 KiB
TypeScript
Raw Normal View History

2022-07-11 09:15:30 +01:00
import { Application } from "express";
import {Module} from "module";
import * as wm from "../wmmt/wm.proto";
2022-07-11 09:15:30 +01:00
export default class StartupModule extends Module {
register(app: Application): void {
2022-07-11 11:45:36 +01:00
app.post('/method/register_system_info', (req, res) => {
let msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
regionId: 1,
2022-07-11 12:29:28 +01:00
placeId: "JPN0123",
allowedClientLogTypes: [],
ghostSelectionMinRedoWait: 30,
ghostSelectionMaxRedoWait: 4000,
2022-07-11 11:45:36 +01:00
featureVersion: {
version: 9,
2022-07-11 11:45:36 +01:00
year: 2022,
month: 7,
pluses: 0,
releaseAt: 0 // idk what this is
}
2022-07-11 11:45:36 +01:00
}
let resp = wm.wm.protobuf.RegisterSystemInfoResponse.encode(msg);
2022-07-11 11:45:36 +01:00
let end = resp.finish();
let r = res
.header('Server', 'v388 wangan')
.header('Content-Type', 'application/x-protobuf; revision=8053')
2022-07-11 11:38:21 +01:00
.header('Content-Length', end.length.toString())
.status(200);
r.send(Buffer.from(end));
})
app.get('/resource/place_list', (req, res) => {
console.log('place list');
let places: wm.wm.protobuf.Place[] = [];
places.push(new wm.wm.protobuf.Place({
2022-07-11 12:29:28 +01:00
placeId: "JPN0123",
regionId: 1,
shopName: "WMMT6",
country: "JPN"
}));
let resp = wm.wm.protobuf.PlaceList.encode({places});
2022-07-11 12:29:28 +01:00
let end = resp.finish();
let r = res
.header('Server', 'v388 wangan')
.header('Content-Type', 'application/x-protobuf; revision=8053')
2022-07-11 11:38:21 +01:00
.header('Content-Length', end.length.toString())
.status(200);
2022-07-11 12:29:28 +01:00
r.send(Buffer.from(end));
2022-07-11 11:45:36 +01:00
})
app.post('/method/ping', (req, res) => {
console.log('ping');
let body = wm.wm.protobuf.PingRequest.decode(req.body);
let ping = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
pong: body.ping || 1
};
let resp = wm.wm.protobuf.PingResponse.encode(ping);
let end = resp.finish();
let r = res
.header('Server', 'v388 wangan')
.header('Content-Type', 'application/x-protobuf; revision=8053')
.header('Content-Length', end.length.toString())
.status(200);
r.send(Buffer.from(end));
})
2022-07-11 09:15:30 +01:00
}
}