1234567891011121314151617181920212223242526272829 |
- import { eg } from "../frameWork/eg";
- import { GameServerConfig } from "../network/GameServerConfig";
- import { HttpClient as HttpClient_Browser, WsClient as WsClient_Browser } from 'tsrpc-browser';
- import { HttpClient as HttpClient_Miniapp, WsClient as WsClient_Miniapp } from 'tsrpc-miniapp';
- import { serviceProto as ServiceProtoRoom, ServiceType, ServiceType as ServiceTypeRoom } from "../shared/serviceProto";
- import IDataModel from "../frameWork/model/IDataModel";
- import UIHelp, { DialogParams } from "../logic/ui/UIHelp";
- /** 游戏服 */
- export class LoginServerModel extends IDataModel {
- /** 连接网关服务器 Http 客户端 */
- hcGate: HttpClient_Miniapp<ServiceTypeRoom> | HttpClient_Browser<ServiceTypeRoom> = null!;
- Init() {
- this.hcGate = eg.tspcNet.createLoginServer(GameServerConfig.LOGIN_SERVER);
- }
- /** 请求api */
- public async ReqApi<T extends string & keyof ServiceType['api']>(apiName: T, req: ServiceType['api'][T]['req']) {
- let ret = await this.hcGate.callApi(apiName, req);
- if (!ret.isSucc) {
- console.error(ret.err);
- }
- return ret;
- }
- }
|