This commit is contained in:
k8w 2022-04-19 01:23:37 +08:00
parent d2f770d3ad
commit 3fd0679492
28 changed files with 1529 additions and 1105 deletions

View File

@ -15,13 +15,13 @@
"devDependencies": { "devDependencies": {
"@types/mocha": "^8.2.3", "@types/mocha": "^8.2.3",
"@types/node": "^15.14.9", "@types/node": "^15.14.9",
"mocha": "^9.1.3", "mocha": "^9.2.2",
"onchange": "^7.1.0", "onchange": "^7.1.0",
"ts-node": "^10.4.0", "ts-node": "^10.7.0",
"tsrpc-cli": "^2.3.1", "tsrpc-cli": "^2.4.3-dev.1",
"typescript": "^4.5.4" "typescript": "^4.6.3"
}, },
"dependencies": { "dependencies": {
"tsrpc": "^3.1.4" "tsrpc": "^3.3.0"
} }
} }

View File

@ -1,26 +0,0 @@
import { ApiCall } from "tsrpc";
import { server } from "..";
import { ReqSend, ResSend } from "../shared/protocols/PtlSend";
// This is a demo code file
// Feel free to delete it
export async function ApiSend(call: ApiCall<ReqSend, ResSend>) {
// Error
if (call.req.content.length === 0) {
call.error('Content is empty')
return;
}
// Success
let time = new Date();
call.succ({
time: time
});
// Broadcast
server.broadcastMsg('Chat', {
content: call.req.content,
time: time
})
}

View File

@ -0,0 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqRegister, ResRegister } from "../../shared/protocols/hallServer-roomManager/PtlRegister";
export async function ApiRegister(call: ApiCall<ReqRegister, ResRegister>) {
// TODO
call.error('API Not Implemented');
}

View File

@ -0,0 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqCreateRoom, ResCreateRoom } from "../../../shared/protocols/hallServer-roomManager/roomServer/PtlCreateRoom";
export async function ApiCreateRoom(call: ApiCall<ReqCreateRoom, ResCreateRoom>) {
// TODO
call.error('API Not Implemented');
}

View File

@ -0,0 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqPreJoinRoom, ResPreJoinRoom } from "../../../shared/protocols/hallServer-roomManager/roomServer/PtlPreJoinRoom";
export async function ApiPreJoinRoom(call: ApiCall<ReqPreJoinRoom, ResPreJoinRoom>) {
// TODO
call.error('API Not Implemented');
}

View File

@ -0,0 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqCreateRoom, ResCreateRoom } from "../../shared/protocols/hallServer/PtlCreateRoom";
export async function ApiCreateRoom(call: ApiCall<ReqCreateRoom, ResCreateRoom>) {
// TODO
call.error('API Not Implemented');
}

View File

@ -0,0 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqListRooms, ResListRooms } from "../../shared/protocols/hallServer/PtlListRooms";
export async function ApiListRooms(call: ApiCall<ReqListRooms, ResListRooms>) {
// TODO
call.error('API Not Implemented');
}

View File

@ -0,0 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqStartMatch, ResStartMatch } from "../../shared/protocols/hallServer/PtlStartMatch";
export async function ApiStartMatch(call: ApiCall<ReqStartMatch, ResStartMatch>) {
// TODO
call.error('API Not Implemented');
}

View File

@ -0,0 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqExitRoom, ResExitRoom } from "../../shared/protocols/roomServer/PtlExitRoom";
export async function ApiExitRoom(call: ApiCall<ReqExitRoom, ResExitRoom>) {
// TODO
call.error('API Not Implemented');
}

View File

@ -0,0 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqJoinRoom, ResJoinRoom } from "../../shared/protocols/roomServer/PtlJoinRoom";
export async function ApiJoinRoom(call: ApiCall<ReqJoinRoom, ResJoinRoom>) {
// TODO
call.error('API Not Implemented');
}

View File

@ -0,0 +1,7 @@
import { ApiCall } from "tsrpc";
import { ReqUpdateRoomInfo, ResUpdateRoomInfo } from "../../shared/protocols/roomServer/PtlUpdateRoomInfo";
export async function ApiUpdateRoomInfo(call: ApiCall<ReqUpdateRoomInfo, ResUpdateRoomInfo>) {
// TODO
call.error('API Not Implemented');
}

View File

@ -1,7 +0,0 @@
// This is a demo code file
// Feel free to delete it
export interface MsgChat {
content: string,
time: Date
}

View File

@ -1,10 +0,0 @@
// This is a demo code file
// Feel free to delete it
export interface ReqSend {
content: string
}
export interface ResSend {
time: Date
}

View File

@ -1,5 +1,6 @@
export interface BaseRequest { export interface BaseRequest {
/** 登录态 */
sso?: string
} }
export interface BaseResponse { export interface BaseResponse {

View File

@ -0,0 +1,13 @@
import { BaseRequest, BaseResponse, BaseConf } from "./../base";
export interface ReqRegister extends BaseRequest {
}
export interface ResRegister extends BaseResponse {
}
export const conf: BaseConf = {
}

View File

@ -0,0 +1,5 @@
export interface MsgUpdateRoomState {
}
// export const conf = {}

View File

@ -0,0 +1,13 @@
import { BaseRequest, BaseResponse, BaseConf } from "./../../base";
export interface ReqCreateRoom extends BaseRequest {
}
export interface ResCreateRoom extends BaseResponse {
}
export const conf: BaseConf = {
}

View File

@ -0,0 +1,13 @@
import { BaseRequest, BaseResponse, BaseConf } from "./../../base";
export interface ReqPreJoinRoom extends BaseRequest {
}
export interface ResPreJoinRoom extends BaseResponse {
}
export const conf: BaseConf = {
}

View File

@ -0,0 +1,13 @@
import { BaseRequest, BaseResponse, BaseConf } from "./../base";
export interface ReqCreateRoom extends BaseRequest {
}
export interface ResCreateRoom extends BaseResponse {
}
export const conf: BaseConf = {
}

View File

@ -0,0 +1,13 @@
import { BaseRequest, BaseResponse, BaseConf } from "./../base";
export interface ReqListRooms extends BaseRequest {
}
export interface ResListRooms extends BaseResponse {
}
export const conf: BaseConf = {
}

View File

@ -0,0 +1,13 @@
import { BaseRequest, BaseResponse, BaseConf } from "./../base";
export interface ReqStartMatch extends BaseRequest {
}
export interface ResStartMatch extends BaseResponse {
}
export const conf: BaseConf = {
}

View File

@ -0,0 +1,13 @@
import { BaseRequest, BaseResponse, BaseConf } from "./../base";
export interface ReqExitRoom extends BaseRequest {
}
export interface ResExitRoom extends BaseResponse {
}
export const conf: BaseConf = {
}

View File

@ -0,0 +1,13 @@
import { BaseRequest, BaseResponse, BaseConf } from "./../base";
export interface ReqJoinRoom extends BaseRequest {
}
export interface ResJoinRoom extends BaseResponse {
}
export const conf: BaseConf = {
}

View File

@ -0,0 +1,13 @@
import { BaseRequest, BaseResponse, BaseConf } from "./../base";
export interface ReqUpdateRoomInfo extends BaseRequest {
}
export interface ResUpdateRoomInfo extends BaseResponse {
}
export const conf: BaseConf = {
}

View File

@ -0,0 +1,5 @@
export interface MsgChat {
}
// export const conf = {}

View File

@ -0,0 +1,5 @@
export interface MsgUpdateRoomInfo {
}
// export const conf = {}

View File

@ -1,19 +1,60 @@
import { ServiceProto } from 'tsrpc-proto'; import { ServiceProto } from 'tsrpc-proto';
import { MsgChat } from './MsgChat'; import { ReqRegister, ResRegister } from './hallServer-roomManager/PtlRegister';
import { ReqSend, ResSend } from './PtlSend'; import { MsgUpdateRoomState } from './hallServer-roomManager/roomServer/MsgUpdateRoomState';
import { ReqCreateRoom, ResCreateRoom } from './hallServer-roomManager/roomServer/PtlCreateRoom';
// This is a demo service proto file (auto generated) import { ReqPreJoinRoom, ResPreJoinRoom } from './hallServer-roomManager/roomServer/PtlPreJoinRoom';
// Feel free to delete it import { ReqCreateRoom as ReqCreateRoom_1, ResCreateRoom as ResCreateRoom_1 } from './hallServer/PtlCreateRoom';
import { ReqListRooms, ResListRooms } from './hallServer/PtlListRooms';
import { ReqStartMatch, ResStartMatch } from './hallServer/PtlStartMatch';
import { ReqExitRoom, ResExitRoom } from './roomServer/PtlExitRoom';
import { ReqJoinRoom, ResJoinRoom } from './roomServer/PtlJoinRoom';
import { ReqUpdateRoomInfo, ResUpdateRoomInfo } from './roomServer/PtlUpdateRoomInfo';
import { MsgChat } from './roomServer/roomMsg/MsgChat';
import { MsgUpdateRoomInfo } from './roomServer/roomMsg/MsgUpdateRoomInfo';
export interface ServiceType { export interface ServiceType {
api: { api: {
"Send": { "hallServer-roomManager/Register": {
req: ReqSend, req: ReqRegister,
res: ResSend res: ResRegister
},
"hallServer-roomManager/roomServer/CreateRoom": {
req: ReqCreateRoom,
res: ResCreateRoom
},
"hallServer-roomManager/roomServer/PreJoinRoom": {
req: ReqPreJoinRoom,
res: ResPreJoinRoom
},
"hallServer/CreateRoom": {
req: ReqCreateRoom_1,
res: ResCreateRoom_1
},
"hallServer/ListRooms": {
req: ReqListRooms,
res: ResListRooms
},
"hallServer/StartMatch": {
req: ReqStartMatch,
res: ResStartMatch
},
"roomServer/ExitRoom": {
req: ReqExitRoom,
res: ResExitRoom
},
"roomServer/JoinRoom": {
req: ReqJoinRoom,
res: ResJoinRoom
},
"roomServer/UpdateRoomInfo": {
req: ReqUpdateRoomInfo,
res: ResUpdateRoomInfo
} }
}, },
msg: { msg: {
"Chat": MsgChat "hallServer-roomManager/roomServer/UpdateRoomState": MsgUpdateRoomState,
"roomServer/roomMsg/Chat": MsgChat,
"roomServer/roomMsg/UpdateRoomInfo": MsgUpdateRoomInfo
} }
} }
@ -21,58 +62,315 @@ export const serviceProto: ServiceProto<ServiceType> = {
"services": [ "services": [
{ {
"id": 0, "id": 0,
"name": "Chat", "name": "hallServer-roomManager/Register",
"type": "msg" "type": "api",
"conf": {}
}, },
{ {
"id": 1, "id": 1,
"name": "Send", "name": "hallServer-roomManager/roomServer/UpdateRoomState",
"type": "api" "type": "msg"
},
{
"id": 2,
"name": "hallServer-roomManager/roomServer/CreateRoom",
"type": "api",
"conf": {}
},
{
"id": 3,
"name": "hallServer-roomManager/roomServer/PreJoinRoom",
"type": "api",
"conf": {}
},
{
"id": 4,
"name": "hallServer/CreateRoom",
"type": "api",
"conf": {}
},
{
"id": 5,
"name": "hallServer/ListRooms",
"type": "api",
"conf": {}
},
{
"id": 6,
"name": "hallServer/StartMatch",
"type": "api",
"conf": {}
},
{
"id": 7,
"name": "roomServer/ExitRoom",
"type": "api",
"conf": {}
},
{
"id": 8,
"name": "roomServer/JoinRoom",
"type": "api",
"conf": {}
},
{
"id": 9,
"name": "roomServer/UpdateRoomInfo",
"type": "api",
"conf": {}
},
{
"id": 10,
"name": "roomServer/roomMsg/Chat",
"type": "msg"
},
{
"id": 11,
"name": "roomServer/roomMsg/UpdateRoomInfo",
"type": "msg"
} }
], ],
"types": { "types": {
"MsgChat/MsgChat": { "hallServer-roomManager/PtlRegister/ReqRegister": {
"type": "Interface", "type": "Interface",
"properties": [ "extends": [
{ {
"id": 0, "id": 0,
"name": "content",
"type": { "type": {
"type": "String" "type": "Reference",
} "target": "base/BaseRequest"
},
{
"id": 1,
"name": "time",
"type": {
"type": "Date"
} }
} }
] ]
}, },
"PtlSend/ReqSend": { "base/BaseRequest": {
"type": "Interface", "type": "Interface",
"properties": [ "properties": [
{ {
"id": 0, "id": 0,
"name": "content", "name": "sso",
"type": { "type": {
"type": "String" "type": "String"
},
"optional": true
}
]
},
"hallServer-roomManager/PtlRegister/ResRegister": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseResponse"
} }
} }
] ]
}, },
"PtlSend/ResSend": { "base/BaseResponse": {
"type": "Interface"
},
"hallServer-roomManager/roomServer/MsgUpdateRoomState/MsgUpdateRoomState": {
"type": "Interface"
},
"hallServer-roomManager/roomServer/PtlCreateRoom/ReqCreateRoom": {
"type": "Interface", "type": "Interface",
"properties": [ "extends": [
{ {
"id": 0, "id": 0,
"name": "time",
"type": { "type": {
"type": "Date" "type": "Reference",
"target": "base/BaseRequest"
} }
} }
] ]
},
"hallServer-roomManager/roomServer/PtlCreateRoom/ResCreateRoom": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseResponse"
}
}
]
},
"hallServer-roomManager/roomServer/PtlPreJoinRoom/ReqPreJoinRoom": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseRequest"
}
}
]
},
"hallServer-roomManager/roomServer/PtlPreJoinRoom/ResPreJoinRoom": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseResponse"
}
}
]
},
"hallServer/PtlCreateRoom/ReqCreateRoom": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseRequest"
}
}
]
},
"hallServer/PtlCreateRoom/ResCreateRoom": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseResponse"
}
}
]
},
"hallServer/PtlListRooms/ReqListRooms": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseRequest"
}
}
]
},
"hallServer/PtlListRooms/ResListRooms": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseResponse"
}
}
]
},
"hallServer/PtlStartMatch/ReqStartMatch": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseRequest"
}
}
]
},
"hallServer/PtlStartMatch/ResStartMatch": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseResponse"
}
}
]
},
"roomServer/PtlExitRoom/ReqExitRoom": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseRequest"
}
}
]
},
"roomServer/PtlExitRoom/ResExitRoom": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseResponse"
}
}
]
},
"roomServer/PtlJoinRoom/ReqJoinRoom": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseRequest"
}
}
]
},
"roomServer/PtlJoinRoom/ResJoinRoom": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseResponse"
}
}
]
},
"roomServer/PtlUpdateRoomInfo/ReqUpdateRoomInfo": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseRequest"
}
}
]
},
"roomServer/PtlUpdateRoomInfo/ResUpdateRoomInfo": {
"type": "Interface",
"extends": [
{
"id": 0,
"type": {
"type": "Reference",
"target": "base/BaseResponse"
}
}
]
},
"roomServer/roomMsg/MsgChat/MsgChat": {
"type": "Interface"
},
"roomServer/roomMsg/MsgUpdateRoomInfo/MsgUpdateRoomInfo": {
"type": "Interface"
} }
} }
}; };

File diff suppressed because it is too large Load Diff