diff --git a/examples/cocos-room-cluster/backend/package.json b/examples/cocos-room-cluster/backend/package.json index 33d88bd..58f4c99 100644 --- a/examples/cocos-room-cluster/backend/package.json +++ b/examples/cocos-room-cluster/backend/package.json @@ -1,10 +1,9 @@ { - "name": "backend-.", + "name": "backend", "version": "0.1.0", "main": "index.js", "private": true, "scripts": { - "dev": "tsrpc-cli dev", "dev:hall": "tsrpc-cli dev --entry src/hallServer.ts", "dev:room": "tsrpc-cli dev --entry src/roomServer.ts", "build": "tsrpc-cli build", @@ -17,6 +16,7 @@ "devDependencies": { "@types/mocha": "^8.2.3", "@types/node": "^15.14.9", + "@types/uuid": "^8.3.4", "mocha": "^9.2.2", "onchange": "^7.1.0", "ts-node": "^10.7.0", @@ -24,6 +24,7 @@ "typescript": "^4.6.3" }, "dependencies": { - "tsrpc": "^3.3.0" + "tsrpc": "^3.3.0", + "uuid": "^8.3.2" } -} \ No newline at end of file +} diff --git a/examples/cocos-room-cluster/backend/src/HallServer/HallServer.ts b/examples/cocos-room-cluster/backend/src/HallServer/HallServer.ts new file mode 100644 index 0000000..7d2437c --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/HallServer/HallServer.ts @@ -0,0 +1,59 @@ +import path from "path"; +import { HttpServer, WsClient } from "tsrpc"; +import { UserUtil } from "../models/UserUtil"; +import { MsgUpdateRoomState } from "../shared/protocols/roomServer/admin/MsgUpdateRoomState"; +import { serviceProto } from "../shared/protocols/serviceProto_hallServer"; +import { ServiceType as ServiceType_Room } from "../shared/protocols/serviceProto_roomServer"; +import { UserInfo } from "../shared/types/UserInfo"; + +export class HallServer { + readonly server = new HttpServer(serviceProto, { + port: 3000, + // Remove this to use binary mode (remove from the client too) + json: true + }); + + /** 已注册的 RoomServer */ + readonly roomServers: { + url: string, + conn: WsClient, + state?: MsgUpdateRoomState + }[] = []; + + constructor() { + // Flows + // 前置鉴别登录态 + this.server.flows.preApiCallFlow.push(async call => { + call.currentUser = call.req.sso ? await UserUtil.parseSso(call.req.sso) : undefined; + + // 需要登录的接口:前置登录态判定 + if (!call.service.conf?.allowGuest) { + if (!call.currentUser) { + call.error('你还未登录', { code: 'NEED_LOGIN' }); + return undefined; + } + } + + if (call.currentUser) { + call.logger.prefixs.push(`[uid=${call.currentUser.id}]`); + } + + return call; + }); + } + + async init() { + await this.server.autoImplementApi(path.resolve(__dirname, './api')); + } + + async start() { + await this.server.start(); + } +} + +declare module 'tsrpc' { + export interface ApiCall { + /** 只要协议配置的 `allowGuest` 不为 `true`,则必定有值 */ + currentUser?: UserInfo; + } +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/HallServer/api/ApiCreateRoom.ts b/examples/cocos-room-cluster/backend/src/HallServer/api/ApiCreateRoom.ts new file mode 100644 index 0000000..3799642 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/HallServer/api/ApiCreateRoom.ts @@ -0,0 +1,34 @@ +import { ApiCall, TsrpcError } from "tsrpc"; +import { hallServer } from "../../hallServer"; +import { BackConfig } from "../../models/BackConfig"; +import { ReqCreateRoom, ResCreateRoom } from "../../shared/protocols/hallServer/PtlCreateRoom"; + +export async function ApiCreateRoom(call: ApiCall) { + // 挑选一个人数最少的 RoomServer + let server = hallServer.roomServers.filter(v => v.state).orderBy(v => v.state!.userNum)[0]; + if (!server) { + return call.error('没有可用的 RoomServer', { type: TsrpcError.Type.ServerError }); + } + + if (!call.req.roomName) { + return call.error('请输入房间名称'); + } + + // RPC + let op = await server.conn.callApi('admin/CreateRoom', { + adminToken: BackConfig.adminToken, + creator: { + uid: call.currentUser!.id, + nickname: call.currentUser!.nickname + }, + roomName: call.req.roomName + }) + if (!op.isSucc) { + return call.error(op.err); + } + + call.succ({ + serverUrl: server.url, + roomId: op.res.roomId + }) +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/HallServer/api/ApiListRooms.ts b/examples/cocos-room-cluster/backend/src/HallServer/api/ApiListRooms.ts new file mode 100644 index 0000000..821b57a --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/HallServer/api/ApiListRooms.ts @@ -0,0 +1,22 @@ +import { ApiCall } from "tsrpc"; +import { hallServer } from "../../hallServer"; +import { ReqListRooms, ResListRooms } from "../../shared/protocols/hallServer/PtlListRooms"; + +export async function ApiListRooms(call: ApiCall) { + let rooms = hallServer.roomServers.reduce((prev, next) => { + if (next.state) { + prev = prev.concat(next.state.rooms.map(v => ({ + name: v.name, + userNum: v.userNum, + serverUrl: next.url, + roomId: v.id, + updateTime: v.updateTime + }))) + } + return prev; + }, [] as (ResListRooms['rooms'][0] & { updateTime: number })[]) + + call.succ({ + rooms: rooms.orderByDesc(v => v.updateTime).slice(0, 100) + }) +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/HallServer/api/ApiLogin.ts b/examples/cocos-room-cluster/backend/src/HallServer/api/ApiLogin.ts new file mode 100644 index 0000000..1f1f220 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/HallServer/api/ApiLogin.ts @@ -0,0 +1,16 @@ +import { ApiCall } from "tsrpc"; +import uuid from "uuid"; +import { UserUtil } from "../../models/UserUtil"; +import { ReqLogin, ResLogin } from "../../shared/protocols/hallServer/PtlLogin"; +import { UserInfo } from "../../shared/types/UserInfo"; + +export async function ApiLogin(call: ApiCall) { + let uid = uuid.v4(); + let user: UserInfo = { + id: uid, + nickname: call.req.nickname + }; + let sso = await UserUtil.createSso(user) + + call.succ({ sso, user }) +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/HallServer/api/ApiStartMatch.ts b/examples/cocos-room-cluster/backend/src/HallServer/api/ApiStartMatch.ts new file mode 100644 index 0000000..a42b165 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/HallServer/api/ApiStartMatch.ts @@ -0,0 +1,7 @@ +import { ApiCall } from "tsrpc"; +import { ReqStartMatch, ResStartMatch } from "../../shared/protocols/hallServer/PtlStartMatch"; + +export async function ApiStartMatch(call: ApiCall) { + // TODO + call.error('API Not Implemented'); +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/HallServer/api/admin/ApiRegisterRoomServer.ts b/examples/cocos-room-cluster/backend/src/HallServer/api/admin/ApiRegisterRoomServer.ts new file mode 100644 index 0000000..a9e0076 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/HallServer/api/admin/ApiRegisterRoomServer.ts @@ -0,0 +1,56 @@ +import { ApiCall, TerminalColorLogger, WsClient } from "tsrpc"; +import { hallServer } from "../../../hallServer"; +import { BackConfig } from "../../../models/BackConfig"; +import { ReqRegisterRoomServer, ResRegisterRoomServer } from "../../../shared/protocols/hallServer/admin/PtlRegisterRoomServer"; +import { serviceProto } from "../../../shared/protocols/serviceProto_roomServer"; +import { HallServer } from "../../HallServer"; + +let nextRoomIndex = 1; + +export async function ApiRegisterRoomServer(call: ApiCall) { + // 鉴权 + if (call.req.adminToken !== BackConfig.adminToken) { + return call.error('非法操作'); + } + + // Create + let client = new WsClient(serviceProto, { + server: call.req.serverUrl, + logger: new TerminalColorLogger({ + pid: `RoomServer${nextRoomIndex++}` + }), + heartbeat: { + interval: 5000, + timeout: 5000 + } + }); + + // Flows + client.flows.postDisconnectFlow.push(v => { + hallServer.roomServers.remove(v1 => v1.conn === client); + return v; + }); + client.listenMsg('admin/UpdateRoomState', msg => { + roomServer.state = msg; + }); + + // Connect + let op = await client.connect(); + if (!op.isSucc) { + return call.error(op.errMsg); + } + + // Auth + let op2 = await client.callApi('admin/Auth', { adminToken: call.req.adminToken }); + if (!op2.isSucc) { + return call.error(op2.err); + } + + // Succ + let roomServer: HallServer['roomServers'][number] = { + url: call.req.serverUrl, + conn: client + } + hallServer.roomServers.push(roomServer); + call.succ({}); +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/RoomServer/RoomServer.ts b/examples/cocos-room-cluster/backend/src/RoomServer/RoomServer.ts new file mode 100644 index 0000000..a2013d6 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/RoomServer/RoomServer.ts @@ -0,0 +1,44 @@ +import path from "path"; +import { WsServer } from "tsrpc"; +import { Room } from "../models/Room"; +import { serviceProto } from "../shared/protocols/serviceProto_roomServer"; +import { UserInfo } from "../shared/types/UserInfo"; + +export class RoomServer { + readonly server = new WsServer(serviceProto, { + port: parseInt(process.env['PORT'] || '3001'), + // Remove this to use binary mode (remove from the client too) + json: true + }); + + constructor() { + // Flows + // 前置鉴别登录态 + this.server.flows.preApiCallFlow.push(async call => { + // 需要登录的接口:前置登录态判定 + if (!call.service.conf?.allowGuest) { + if (!call.conn.currentUser) { + call.error('你还未登录', { code: 'NEED_LOGIN' }); + return undefined; + } + } + + return call; + }); + } + + async init() { + await this.server.autoImplementApi(path.resolve(__dirname, './api')); + } + + async start() { + await this.server.start(); + } +} + +declare module 'tsrpc' { + export interface BaseConnection { + currentUser?: UserInfo; + currentRoom?: Room; + } +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/RoomServer/api/ApiExitRoom.ts b/examples/cocos-room-cluster/backend/src/RoomServer/api/ApiExitRoom.ts new file mode 100644 index 0000000..b32e0bd --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/RoomServer/api/ApiExitRoom.ts @@ -0,0 +1,7 @@ +import { ApiCall } from "tsrpc"; +import { ReqExitRoom, ResExitRoom } from "../../shared/protocols/roomServer/PtlExitRoom"; + +export async function ApiExitRoom(call: ApiCall) { + // TODO + call.error('API Not Implemented'); +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/RoomServer/api/ApiJoinRoom.ts b/examples/cocos-room-cluster/backend/src/RoomServer/api/ApiJoinRoom.ts new file mode 100644 index 0000000..d74df22 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/RoomServer/api/ApiJoinRoom.ts @@ -0,0 +1,7 @@ +import { ApiCall } from "tsrpc"; +import { ReqJoinRoom, ResJoinRoom } from "../../shared/protocols/roomServer/PtlJoinRoom"; + +export async function ApiJoinRoom(call: ApiCall) { + // TODO + call.error('API Not Implemented'); +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/RoomServer/api/ApiUpdateRoom.ts b/examples/cocos-room-cluster/backend/src/RoomServer/api/ApiUpdateRoom.ts new file mode 100644 index 0000000..ecbbf6f --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/RoomServer/api/ApiUpdateRoom.ts @@ -0,0 +1,7 @@ +import { ApiCall } from "tsrpc"; +import { ReqUpdateRoom, ResUpdateRoom } from "../../shared/protocols/roomServer/PtlUpdateRoom"; + +export async function ApiUpdateRoom(call: ApiCall) { + // TODO + call.error('API Not Implemented'); +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/RoomServer/api/admin/ApiAuth.ts b/examples/cocos-room-cluster/backend/src/RoomServer/api/admin/ApiAuth.ts new file mode 100644 index 0000000..a8ea7d9 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/RoomServer/api/admin/ApiAuth.ts @@ -0,0 +1,7 @@ +import { ApiCall } from "tsrpc"; +import { ReqAuth, ResAuth } from "../../../shared/protocols/roomServer/admin/PtlAuth"; + +export async function ApiAuth(call: ApiCall) { + // TODO + call.error('API Not Implemented'); +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/RoomServer/api/admin/ApiCreateRoom.ts b/examples/cocos-room-cluster/backend/src/RoomServer/api/admin/ApiCreateRoom.ts new file mode 100644 index 0000000..dde4ab8 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/RoomServer/api/admin/ApiCreateRoom.ts @@ -0,0 +1,7 @@ +import { ApiCall } from "tsrpc"; +import { ReqCreateRoom, ResCreateRoom } from "../../../shared/protocols/roomServer/admin/PtlCreateRoom"; + +export async function ApiCreateRoom(call: ApiCall) { + // TODO + call.error('API Not Implemented'); +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/hallServer.ts b/examples/cocos-room-cluster/backend/src/hallServer.ts new file mode 100644 index 0000000..65b1300 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/hallServer.ts @@ -0,0 +1,11 @@ +import { HallServer } from "./HallServer/HallServer"; + +export const hallServer = new HallServer(); + +// Entry function +async function main() { + await hallServer.init(); + await hallServer.start(); +} +main(); + diff --git a/examples/cocos-room-cluster/backend/src/index.ts b/examples/cocos-room-cluster/backend/src/index.ts deleted file mode 100644 index 71d481a..0000000 --- a/examples/cocos-room-cluster/backend/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import * as path from "path"; -import { WsServer } from "tsrpc"; -import { serviceProto } from './shared/protocols/serviceProto'; - -// Create the Server -export const server = new WsServer(serviceProto, { - port: 3000, - // Remove this to use binary mode (remove from the client too) - json: true -}); - -// Initialize before server start -async function init() { - await server.autoImplementApi(path.resolve(__dirname, 'api')); - - // TODO - // Prepare something... (e.g. connect the db) -}; - -// Entry function -async function main() { - await init(); - await server.start(); -} -main(); \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/models/BackConfig.ts b/examples/cocos-room-cluster/backend/src/models/BackConfig.ts new file mode 100644 index 0000000..3e8b152 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/models/BackConfig.ts @@ -0,0 +1,5 @@ +export const BackConfig = { + + adminToken: 'AAABBBCCC' + +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/models/Room.ts b/examples/cocos-room-cluster/backend/src/models/Room.ts new file mode 100644 index 0000000..2f868ae --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/models/Room.ts @@ -0,0 +1,3 @@ +export class Room { + +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/models/UserUtil.ts b/examples/cocos-room-cluster/backend/src/models/UserUtil.ts new file mode 100644 index 0000000..4bb9de3 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/models/UserUtil.ts @@ -0,0 +1,21 @@ +import { UserInfo } from "../shared/types/UserInfo"; + +// 登录态 SSO 的编解码 +// 这里简单起见,使用未加密的 JSON 字符串 +// 你可以根据自己的需要,改为加密字符串,或者服务端 Session Key 等 +export class UserUtil { + + static async createSso(user: UserInfo): Promise { + return JSON.stringify(user); + } + + static async parseSso(sso: string): Promise { + try { + return JSON.parse(sso); + } + catch { + return undefined; + } + } + +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/roomServer.ts b/examples/cocos-room-cluster/backend/src/roomServer.ts new file mode 100644 index 0000000..ad2aa09 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/roomServer.ts @@ -0,0 +1,10 @@ +import { RoomServer } from "./RoomServer/RoomServer"; + +export const roomServer = new RoomServer(); + +// Entry function +async function main() { + await roomServer.init(); + await roomServer.start(); +} +main(); \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/server_rpc/serviceProto_hallServer.ts b/examples/cocos-room-cluster/backend/src/server_rpc/serviceProto_hallServer.ts deleted file mode 100644 index afdb60e..0000000 --- a/examples/cocos-room-cluster/backend/src/server_rpc/serviceProto_hallServer.ts +++ /dev/null @@ -1,188 +0,0 @@ -import { ServiceProto } from 'tsrpc-proto'; -import { ReqRegisterRoomServer, ResRegisterRoomServer } from '../shared/protocols/hallServer/admin/PtlRegisterRoomServer'; -import { ReqCreateRoom, ResCreateRoom } from '../shared/protocols/hallServer/PtlCreateRoom'; -import { ReqListRooms, ResListRooms } from '../shared/protocols/hallServer/PtlListRooms'; -import { ReqLogin, ResLogin } from '../shared/protocols/hallServer/PtlLogin'; -import { ReqStartMatch, ResStartMatch } from '../shared/protocols/hallServer/PtlStartMatch'; - -export interface ServiceType { - api: { - "admin/RegisterRoomServer": { - req: ReqRegisterRoomServer, - res: ResRegisterRoomServer - }, - "CreateRoom": { - req: ReqCreateRoom, - res: ResCreateRoom - }, - "ListRooms": { - req: ReqListRooms, - res: ResListRooms - }, - "Login": { - req: ReqLogin, - res: ResLogin - }, - "StartMatch": { - req: ReqStartMatch, - res: ResStartMatch - } - }, - msg: { - - } -} - -export const serviceProto: ServiceProto = { - "services": [ - { - "id": 0, - "name": "admin/RegisterRoomServer", - "type": "api", - "conf": {} - }, - { - "id": 1, - "name": "CreateRoom", - "type": "api", - "conf": {} - }, - { - "id": 2, - "name": "ListRooms", - "type": "api", - "conf": {} - }, - { - "id": 3, - "name": "Login", - "type": "api" - }, - { - "id": 4, - "name": "StartMatch", - "type": "api", - "conf": {} - } - ], - "types": { - "admin/PtlRegisterRoomServer/ReqRegisterRoomServer": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseRequest" - } - } - ] - }, - "../base/BaseRequest": { - "type": "Interface", - "properties": [ - { - "id": 0, - "name": "sso", - "type": { - "type": "String" - }, - "optional": true - } - ] - }, - "admin/PtlRegisterRoomServer/ResRegisterRoomServer": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseResponse" - } - } - ] - }, - "../base/BaseResponse": { - "type": "Interface" - }, - "PtlCreateRoom/ReqCreateRoom": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseRequest" - } - } - ] - }, - "PtlCreateRoom/ResCreateRoom": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseResponse" - } - } - ] - }, - "PtlListRooms/ReqListRooms": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseRequest" - } - } - ] - }, - "PtlListRooms/ResListRooms": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseResponse" - } - } - ] - }, - "PtlLogin/ReqLogin": { - "type": "Interface" - }, - "PtlLogin/ResLogin": { - "type": "Interface" - }, - "PtlStartMatch/ReqStartMatch": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseRequest" - } - } - ] - }, - "PtlStartMatch/ResStartMatch": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseResponse" - } - } - ] - } - } -}; \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/server_rpc/serviceProto_roomServer.ts b/examples/cocos-room-cluster/backend/src/server_rpc/serviceProto_roomServer.ts deleted file mode 100644 index 812048d..0000000 --- a/examples/cocos-room-cluster/backend/src/server_rpc/serviceProto_roomServer.ts +++ /dev/null @@ -1,252 +0,0 @@ -import { ServiceProto } from 'tsrpc-proto'; -import { MsgUpdateRoomState } from '../shared/protocols/roomServer/admin/MsgUpdateRoomState'; -import { ReqAuth, ResAuth } from '../shared/protocols/roomServer/admin/PtlAuth'; -import { ReqCreateRoom, ResCreateRoom } from '../shared/protocols/roomServer/admin/PtlCreateRoom'; -import { ReqPreJoinRoom, ResPreJoinRoom } from '../shared/protocols/roomServer/admin/PtlPreJoinRoom'; -import { ReqExitRoom, ResExitRoom } from '../shared/protocols/roomServer/PtlExitRoom'; -import { ReqJoinRoom, ResJoinRoom } from '../shared/protocols/roomServer/PtlJoinRoom'; -import { ReqUpdateRoom, ResUpdateRoom } from '../shared/protocols/roomServer/PtlUpdateRoom'; -import { MsgChat } from '../shared/protocols/roomServer/roomMsg/MsgChat'; -import { MsgUpdateRoomInfo } from '../shared/protocols/roomServer/roomMsg/MsgUpdateRoomInfo'; - -export interface ServiceType { - api: { - "admin/Auth": { - req: ReqAuth, - res: ResAuth - }, - "admin/CreateRoom": { - req: ReqCreateRoom, - res: ResCreateRoom - }, - "admin/PreJoinRoom": { - req: ReqPreJoinRoom, - res: ResPreJoinRoom - }, - "ExitRoom": { - req: ReqExitRoom, - res: ResExitRoom - }, - "JoinRoom": { - req: ReqJoinRoom, - res: ResJoinRoom - }, - "UpdateRoom": { - req: ReqUpdateRoom, - res: ResUpdateRoom - } - }, - msg: { - "admin/UpdateRoomState": MsgUpdateRoomState, - "roomMsg/Chat": MsgChat, - "roomMsg/UpdateRoomInfo": MsgUpdateRoomInfo - } -} - -export const serviceProto: ServiceProto = { - "services": [ - { - "id": 0, - "name": "admin/UpdateRoomState", - "type": "msg" - }, - { - "id": 1, - "name": "admin/Auth", - "type": "api" - }, - { - "id": 2, - "name": "admin/CreateRoom", - "type": "api", - "conf": {} - }, - { - "id": 3, - "name": "admin/PreJoinRoom", - "type": "api", - "conf": {} - }, - { - "id": 4, - "name": "ExitRoom", - "type": "api", - "conf": {} - }, - { - "id": 5, - "name": "JoinRoom", - "type": "api", - "conf": {} - }, - { - "id": 6, - "name": "UpdateRoom", - "type": "api", - "conf": {} - }, - { - "id": 7, - "name": "roomMsg/Chat", - "type": "msg" - }, - { - "id": 8, - "name": "roomMsg/UpdateRoomInfo", - "type": "msg" - } - ], - "types": { - "admin/MsgUpdateRoomState/MsgUpdateRoomState": { - "type": "Interface" - }, - "admin/PtlAuth/ReqAuth": { - "type": "Interface" - }, - "admin/PtlAuth/ResAuth": { - "type": "Interface" - }, - "admin/PtlCreateRoom/ReqCreateRoom": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseRequest" - } - } - ] - }, - "../base/BaseRequest": { - "type": "Interface", - "properties": [ - { - "id": 0, - "name": "sso", - "type": { - "type": "String" - }, - "optional": true - } - ] - }, - "admin/PtlCreateRoom/ResCreateRoom": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseResponse" - } - } - ] - }, - "../base/BaseResponse": { - "type": "Interface" - }, - "admin/PtlPreJoinRoom/ReqPreJoinRoom": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseRequest" - } - } - ] - }, - "admin/PtlPreJoinRoom/ResPreJoinRoom": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseResponse" - } - } - ] - }, - "PtlExitRoom/ReqExitRoom": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseRequest" - } - } - ] - }, - "PtlExitRoom/ResExitRoom": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseResponse" - } - } - ] - }, - "PtlJoinRoom/ReqJoinRoom": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseRequest" - } - } - ] - }, - "PtlJoinRoom/ResJoinRoom": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseResponse" - } - } - ] - }, - "PtlUpdateRoom/ReqUpdateRoom": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseRequest" - } - } - ] - }, - "PtlUpdateRoom/ResUpdateRoom": { - "type": "Interface", - "extends": [ - { - "id": 0, - "type": { - "type": "Reference", - "target": "../base/BaseResponse" - } - } - ] - }, - "roomMsg/MsgChat/MsgChat": { - "type": "Interface" - }, - "roomMsg/MsgUpdateRoomInfo/MsgUpdateRoomInfo": { - "type": "Interface" - } - } -}; \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlCreateRoom.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlCreateRoom.ts index 2423496..7859931 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlCreateRoom.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlCreateRoom.ts @@ -1,13 +1,14 @@ -import { BaseRequest, BaseResponse, BaseConf } from "./../base"; +import { BaseConf, BaseRequest, BaseResponse } from "./../base"; export interface ReqCreateRoom extends BaseRequest { - + roomName: string } export interface ResCreateRoom extends BaseResponse { - + serverUrl: string, + roomId: string } export const conf: BaseConf = { - + } \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlListRooms.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlListRooms.ts index 15128bb..3953173 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlListRooms.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlListRooms.ts @@ -1,13 +1,19 @@ -import { BaseRequest, BaseResponse, BaseConf } from "./../base"; +import { uint } from "tsrpc"; +import { BaseConf, BaseRequest, BaseResponse } from "./../base"; export interface ReqListRooms extends BaseRequest { - + } export interface ResListRooms extends BaseResponse { - + rooms: { + name: string, + userNum: uint, + serverUrl: string, + roomId: string + }[] } export const conf: BaseConf = { - + } \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlLogin.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlLogin.ts index 1abd323..50b63c8 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlLogin.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlLogin.ts @@ -1,9 +1,15 @@ +import { UserInfo } from "../../types/UserInfo"; +import { BaseConf } from "../base"; + export interface ReqLogin { - + nickname: string } export interface ResLogin { - + sso: string, + user: UserInfo } -// export const conf = {} \ No newline at end of file +export const conf: BaseConf = { + allowGuest: true +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlStartMatch.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlStartMatch.ts index 478b78c..8563c19 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlStartMatch.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/PtlStartMatch.ts @@ -1,13 +1,15 @@ -import { BaseRequest, BaseResponse, BaseConf } from "./../base"; +import { uint } from "tsrpc-proto"; +import { BaseConf, BaseRequest, BaseResponse } from "./../base"; export interface ReqStartMatch extends BaseRequest { - + } export interface ResStartMatch extends BaseResponse { - + serverUrl: string, + roomId: uint } export const conf: BaseConf = { - + } \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/admin/PtlRegisterRoomServer.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/admin/PtlRegisterRoomServer.ts index 468bf5c..1dcf097 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/admin/PtlRegisterRoomServer.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/hallServer/admin/PtlRegisterRoomServer.ts @@ -1,13 +1,12 @@ -import { BaseConf, BaseRequest, BaseResponse } from "../../base"; - -export interface ReqRegisterRoomServer extends BaseRequest { +import { BaseConf } from "../../base"; +export interface ReqRegisterRoomServer { + /** RoomServer 的连接地址 */ + serverUrl: string, + /** Token 用于鉴权 */ + adminToken: string } -export interface ResRegisterRoomServer extends BaseResponse { - -} - -export const conf: BaseConf = { +export interface ResRegisterRoomServer { } \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/PtlExitRoom.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/PtlExitRoom.ts index b445fa6..4a0368d 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/PtlExitRoom.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/PtlExitRoom.ts @@ -1,13 +1,13 @@ -import { BaseRequest, BaseResponse, BaseConf } from "./../base"; +import { BaseConf, BaseRequest, BaseResponse } from "./../base"; export interface ReqExitRoom extends BaseRequest { - + } export interface ResExitRoom extends BaseResponse { - + } export const conf: BaseConf = { - + } \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/PtlJoinRoom.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/PtlJoinRoom.ts index 0f60e7e..5e5537b 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/PtlJoinRoom.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/PtlJoinRoom.ts @@ -1,7 +1,7 @@ import { BaseRequest, BaseResponse, BaseConf } from "./../base"; export interface ReqJoinRoom extends BaseRequest { - + roomId: string } export interface ResJoinRoom extends BaseResponse { diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/PtlUpdateRoom.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/PtlUpdateRoom.ts index 0099a55..2894f4c 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/PtlUpdateRoom.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/PtlUpdateRoom.ts @@ -1,7 +1,8 @@ import { BaseConf, BaseRequest, BaseResponse } from "../base"; export interface ReqUpdateRoom extends BaseRequest { - + roomId: string, + roomName: string } export interface ResUpdateRoom extends BaseResponse { diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/MsgUpdateRoomState.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/MsgUpdateRoomState.ts index fadb762..3f1b01a 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/MsgUpdateRoomState.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/MsgUpdateRoomState.ts @@ -1,5 +1,16 @@ +import { uint } from "tsrpc-proto"; + export interface MsgUpdateRoomState { - + userNum: uint, + rooms: { + id: string, + name: string, + userNum: uint, + /** 为 undefined 代表不在匹配中 */ + startMatchTime?: uint, + // 房间信息的最后更新时间 + updateTime: uint + }[] } // export const conf = {} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/PtlAuth.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/PtlAuth.ts index 8d9dc63..ab01756 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/PtlAuth.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/PtlAuth.ts @@ -1,9 +1,8 @@ + export interface ReqAuth { - + adminToken: string } export interface ResAuth { - -} -// export const conf = {} \ No newline at end of file +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/PtlCreateRoom.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/PtlCreateRoom.ts index 9f1d62d..1234093 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/PtlCreateRoom.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/PtlCreateRoom.ts @@ -1,13 +1,13 @@ -import { BaseRequest, BaseResponse, BaseConf } from "./../../base"; -export interface ReqCreateRoom extends BaseRequest { - +export interface ReqCreateRoom { + adminToken: string, + creator: { + uid: string, + nickname: string + } + roomName: string } -export interface ResCreateRoom extends BaseResponse { - -} - -export const conf: BaseConf = { - +export interface ResCreateRoom { + roomId: string } \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/PtlPreJoinRoom.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/PtlPreJoinRoom.ts deleted file mode 100644 index 0d98a10..0000000 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/roomServer/admin/PtlPreJoinRoom.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { BaseRequest, BaseResponse, BaseConf } from "./../../base"; - -export interface ReqPreJoinRoom extends BaseRequest { - -} - -export interface ResPreJoinRoom extends BaseResponse { - -} - -export const conf: BaseConf = { - -} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/serviceProto_hallServer.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/serviceProto_hallServer.ts index a1099c1..ee5e6cd 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/serviceProto_hallServer.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/serviceProto_hallServer.ts @@ -1,4 +1,5 @@ import { ServiceProto } from 'tsrpc-proto'; +import { ReqRegisterRoomServer, ResRegisterRoomServer } from './hallServer/admin/PtlRegisterRoomServer'; import { ReqCreateRoom, ResCreateRoom } from './hallServer/PtlCreateRoom'; import { ReqListRooms, ResListRooms } from './hallServer/PtlListRooms'; import { ReqLogin, ResLogin } from './hallServer/PtlLogin'; @@ -6,6 +7,10 @@ import { ReqStartMatch, ResStartMatch } from './hallServer/PtlStartMatch'; export interface ServiceType { api: { + "admin/RegisterRoomServer": { + req: ReqRegisterRoomServer, + res: ResRegisterRoomServer + }, "CreateRoom": { req: ReqCreateRoom, res: ResCreateRoom @@ -29,8 +34,13 @@ export interface ServiceType { } export const serviceProto: ServiceProto = { - "version": 1, + "version": 2, "services": [ + { + "id": 0, + "name": "admin/RegisterRoomServer", + "type": "api" + }, { "id": 1, "name": "CreateRoom", @@ -46,7 +56,10 @@ export const serviceProto: ServiceProto = { { "id": 3, "name": "Login", - "type": "api" + "type": "api", + "conf": { + "allowGuest": true + } }, { "id": 4, @@ -56,6 +69,28 @@ export const serviceProto: ServiceProto = { } ], "types": { + "admin/PtlRegisterRoomServer/ReqRegisterRoomServer": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "serverUrl", + "type": { + "type": "String" + } + }, + { + "id": 1, + "name": "adminToken", + "type": { + "type": "String" + } + } + ] + }, + "admin/PtlRegisterRoomServer/ResRegisterRoomServer": { + "type": "Interface" + }, "PtlCreateRoom/ReqCreateRoom": { "type": "Interface", "extends": [ @@ -66,6 +101,15 @@ export const serviceProto: ServiceProto = { "target": "../base/BaseRequest" } } + ], + "properties": [ + { + "id": 0, + "name": "roomName", + "type": { + "type": "String" + } + } ] }, "../base/BaseRequest": { @@ -91,6 +135,22 @@ export const serviceProto: ServiceProto = { "target": "../base/BaseResponse" } } + ], + "properties": [ + { + "id": 0, + "name": "serverUrl", + "type": { + "type": "String" + } + }, + { + "id": 1, + "name": "roomId", + "type": { + "type": "String" + } + } ] }, "../base/BaseResponse": { @@ -118,13 +178,101 @@ export const serviceProto: ServiceProto = { "target": "../base/BaseResponse" } } + ], + "properties": [ + { + "id": 0, + "name": "rooms", + "type": { + "type": "Array", + "elementType": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "name", + "type": { + "type": "String" + } + }, + { + "id": 4, + "name": "userNum", + "type": { + "type": "Number", + "scalarType": "uint" + } + }, + { + "id": 2, + "name": "serverUrl", + "type": { + "type": "String" + } + }, + { + "id": 3, + "name": "roomId", + "type": { + "type": "String" + } + } + ] + } + } + } ] }, "PtlLogin/ReqLogin": { - "type": "Interface" + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "nickname", + "type": { + "type": "String" + } + } + ] }, "PtlLogin/ResLogin": { - "type": "Interface" + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "sso", + "type": { + "type": "String" + } + }, + { + "id": 1, + "name": "user", + "type": { + "type": "Reference", + "target": "../../types/UserInfo/UserInfo" + } + } + ] + }, + "../../types/UserInfo/UserInfo": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "id", + "type": { + "type": "String" + } + }, + { + "id": 1, + "name": "nickname", + "type": { + "type": "String" + } + } + ] }, "PtlStartMatch/ReqStartMatch": { "type": "Interface", @@ -148,6 +296,23 @@ export const serviceProto: ServiceProto = { "target": "../base/BaseResponse" } } + ], + "properties": [ + { + "id": 0, + "name": "serverUrl", + "type": { + "type": "String" + } + }, + { + "id": 1, + "name": "roomId", + "type": { + "type": "Number", + "scalarType": "uint" + } + } ] } } diff --git a/examples/cocos-room-cluster/backend/src/shared/protocols/serviceProto_roomServer.ts b/examples/cocos-room-cluster/backend/src/shared/protocols/serviceProto_roomServer.ts index 75f3d15..7db8c04 100644 --- a/examples/cocos-room-cluster/backend/src/shared/protocols/serviceProto_roomServer.ts +++ b/examples/cocos-room-cluster/backend/src/shared/protocols/serviceProto_roomServer.ts @@ -1,4 +1,7 @@ import { ServiceProto } from 'tsrpc-proto'; +import { MsgUpdateRoomState } from './roomServer/admin/MsgUpdateRoomState'; +import { ReqAuth, ResAuth } from './roomServer/admin/PtlAuth'; +import { ReqCreateRoom, ResCreateRoom } from './roomServer/admin/PtlCreateRoom'; import { ReqExitRoom, ResExitRoom } from './roomServer/PtlExitRoom'; import { ReqJoinRoom, ResJoinRoom } from './roomServer/PtlJoinRoom'; import { ReqUpdateRoom, ResUpdateRoom } from './roomServer/PtlUpdateRoom'; @@ -7,6 +10,14 @@ import { MsgUpdateRoomInfo } from './roomServer/roomMsg/MsgUpdateRoomInfo'; export interface ServiceType { api: { + "admin/Auth": { + req: ReqAuth, + res: ResAuth + }, + "admin/CreateRoom": { + req: ReqCreateRoom, + res: ResCreateRoom + }, "ExitRoom": { req: ReqExitRoom, res: ResExitRoom @@ -21,44 +32,193 @@ export interface ServiceType { } }, msg: { + "admin/UpdateRoomState": MsgUpdateRoomState, "roomMsg/Chat": MsgChat, "roomMsg/UpdateRoomInfo": MsgUpdateRoomInfo } } export const serviceProto: ServiceProto = { - "version": 1, + "version": 2, "services": [ { - "id": 4, + "id": 0, + "name": "admin/UpdateRoomState", + "type": "msg" + }, + { + "id": 1, + "name": "admin/Auth", + "type": "api" + }, + { + "id": 2, + "name": "admin/CreateRoom", + "type": "api" + }, + { + "id": 3, "name": "ExitRoom", "type": "api", "conf": {} }, { - "id": 5, + "id": 4, "name": "JoinRoom", "type": "api", "conf": {} }, { - "id": 6, + "id": 5, "name": "UpdateRoom", "type": "api", "conf": {} }, { - "id": 7, + "id": 6, "name": "roomMsg/Chat", "type": "msg" }, { - "id": 8, + "id": 7, "name": "roomMsg/UpdateRoomInfo", "type": "msg" } ], "types": { + "admin/MsgUpdateRoomState/MsgUpdateRoomState": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "userNum", + "type": { + "type": "Number", + "scalarType": "uint" + } + }, + { + "id": 1, + "name": "rooms", + "type": { + "type": "Array", + "elementType": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "id", + "type": { + "type": "String" + } + }, + { + "id": 1, + "name": "name", + "type": { + "type": "String" + } + }, + { + "id": 2, + "name": "userNum", + "type": { + "type": "Number", + "scalarType": "uint" + } + }, + { + "id": 3, + "name": "startMatchTime", + "type": { + "type": "Number", + "scalarType": "uint" + }, + "optional": true + }, + { + "id": 4, + "name": "updateTime", + "type": { + "type": "Number", + "scalarType": "uint" + } + } + ] + } + } + } + ] + }, + "admin/PtlAuth/ReqAuth": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "adminToken", + "type": { + "type": "String" + } + } + ] + }, + "admin/PtlAuth/ResAuth": { + "type": "Interface" + }, + "admin/PtlCreateRoom/ReqCreateRoom": { + "type": "Interface", + "properties": [ + { + "id": 2, + "name": "adminToken", + "type": { + "type": "String" + } + }, + { + "id": 3, + "name": "creator", + "type": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "uid", + "type": { + "type": "String" + } + }, + { + "id": 1, + "name": "nickname", + "type": { + "type": "String" + } + } + ] + } + }, + { + "id": 1, + "name": "roomName", + "type": { + "type": "String" + } + } + ] + }, + "admin/PtlCreateRoom/ResCreateRoom": { + "type": "Interface", + "properties": [ + { + "id": 1, + "name": "roomId", + "type": { + "type": "String" + } + } + ] + }, "PtlExitRoom/ReqExitRoom": { "type": "Interface", "extends": [ @@ -109,6 +269,15 @@ export const serviceProto: ServiceProto = { "target": "../base/BaseRequest" } } + ], + "properties": [ + { + "id": 0, + "name": "roomId", + "type": { + "type": "String" + } + } ] }, "PtlJoinRoom/ResJoinRoom": { @@ -133,6 +302,22 @@ export const serviceProto: ServiceProto = { "target": "../base/BaseRequest" } } + ], + "properties": [ + { + "id": 0, + "name": "roomId", + "type": { + "type": "String" + } + }, + { + "id": 1, + "name": "roomName", + "type": { + "type": "String" + } + } ] }, "PtlUpdateRoom/ResUpdateRoom": { diff --git a/examples/cocos-room-cluster/backend/src/shared/types/UserInfo.ts b/examples/cocos-room-cluster/backend/src/shared/types/UserInfo.ts new file mode 100644 index 0000000..b018d53 --- /dev/null +++ b/examples/cocos-room-cluster/backend/src/shared/types/UserInfo.ts @@ -0,0 +1,4 @@ +export interface UserInfo { + id: string, + nickname: string +} \ No newline at end of file diff --git a/examples/cocos-room-cluster/backend/tsrpc.config.ts b/examples/cocos-room-cluster/backend/tsrpc.config.ts index b8c7a00..3108783 100644 --- a/examples/cocos-room-cluster/backend/tsrpc.config.ts +++ b/examples/cocos-room-cluster/backend/tsrpc.config.ts @@ -3,31 +3,18 @@ import { CodeTemplate, TsrpcConfig } from 'tsrpc-cli'; const tsrpcConf: TsrpcConfig = { // Generate ServiceProto proto: [ - // Proto for user { ptlDir: 'src/shared/protocols/hallServer', // Protocol dir output: 'src/shared/protocols/serviceProto_hallServer.ts', // Path for generated ServiceProto - ignore: 'src/shared/protocols/hallServer/admin/**' // User proto ignore admin - }, - { - ptlDir: 'src/shared/protocols/roomServer', // Protocol dir - output: 'src/shared/protocols/serviceProto_roomServer.ts', // Path for generated ServiceProto - ignore: 'src/shared/protocols/roomServer/admin/**' // User proto ignore admin - }, - - // Proto for server RPC - { - ptlDir: 'src/shared/protocols/hallServer', // Protocol dir - output: 'src/server_rpc/serviceProto_hallServer.ts', // Path for generated ServiceProto - apiDir: 'src/api/hallServer', // API dir + apiDir: 'src/HallServer/api', // API dir docDir: 'docs/hallServer', // API documents dir ptlTemplate: CodeTemplate.getExtendedPtl(), // msgTemplate: CodeTemplate.getExtendedMsg(), }, { ptlDir: 'src/shared/protocols/roomServer', // Protocol dir - output: 'src/server_rpc/serviceProto_roomServer.ts', // Path for generated ServiceProto - apiDir: 'src/api/roomServer', // API dir + output: 'src/shared/protocols/serviceProto_roomServer.ts', // Path for generated ServiceProto + apiDir: 'src/RoomServer/api', // API dir docDir: 'docs/roomServer', // API documents dir ptlTemplate: CodeTemplate.getExtendedPtl(), // msgTemplate: CodeTemplate.getExtendedMsg(),