2022-07-11 09:15:30 +01:00
|
|
|
import { Application } from "express";
|
|
|
|
import {Module} from "module";
|
2022-07-11 14:48:39 +01:00
|
|
|
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 = {
|
2022-07-11 14:48:39 +01:00
|
|
|
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
|
2022-07-11 13:43:39 +01:00
|
|
|
regionId: 1,
|
2022-07-11 12:29:28 +01:00
|
|
|
placeId: "JPN0123",
|
2022-07-11 13:43:39 +01:00
|
|
|
allowedClientLogTypes: [],
|
|
|
|
ghostSelectionMinRedoWait: 30,
|
|
|
|
ghostSelectionMaxRedoWait: 4000,
|
2022-07-11 11:45:36 +01:00
|
|
|
featureVersion: {
|
2022-07-11 13:43:39 +01:00
|
|
|
version: 9,
|
2022-07-11 11:45:36 +01:00
|
|
|
year: 2022,
|
|
|
|
month: 7,
|
2022-07-11 13:43:39 +01:00
|
|
|
pluses: 0,
|
|
|
|
releaseAt: 0 // idk what this is
|
2022-07-11 14:48:39 +01:00
|
|
|
}
|
2022-07-11 11:45:36 +01:00
|
|
|
}
|
2022-07-11 14:48:39 +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
|
2022-07-11 13:43:39 +01:00
|
|
|
.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())
|
2022-07-11 13:43:39 +01:00
|
|
|
.status(200);
|
|
|
|
r.send(Buffer.from(end));
|
|
|
|
})
|
|
|
|
|
|
|
|
app.get('/resource/place_list', (req, res) => {
|
|
|
|
console.log('place list');
|
2022-07-11 14:48:39 +01:00
|
|
|
let places: wm.wm.protobuf.Place[] = [];
|
|
|
|
places.push(new wm.wm.protobuf.Place({
|
2022-07-11 12:29:28 +01:00
|
|
|
placeId: "JPN0123",
|
2022-07-11 13:43:39 +01:00
|
|
|
regionId: 1,
|
|
|
|
shopName: "WMMT6",
|
|
|
|
country: "JPN"
|
2022-07-11 14:48:39 +01:00
|
|
|
}));
|
|
|
|
let resp = wm.wm.protobuf.PlaceList.encode({places});
|
2022-07-11 12:29:28 +01:00
|
|
|
let end = resp.finish();
|
2022-07-11 13:43:39 +01:00
|
|
|
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())
|
2022-07-11 13:43:39 +01:00
|
|
|
.status(200);
|
2022-07-11 12:29:28 +01:00
|
|
|
r.send(Buffer.from(end));
|
2022-07-11 11:45:36 +01:00
|
|
|
})
|
2022-07-11 15:19: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
|
|
|
}
|
|
|
|
}
|