重构NetManager支持MessagePair,新增TSRPCWsClient。
This commit is contained in:
@@ -1,29 +1,48 @@
|
||||
/**
|
||||
* 网络协议类型
|
||||
*/
|
||||
export enum NetProtocolType {
|
||||
/** HTTP/HTTPS 协议 */
|
||||
Http = "http",
|
||||
|
||||
/** WebSocket 协议 */
|
||||
WebSocket = "websocket"
|
||||
}
|
||||
|
||||
/**
|
||||
* 网络配置接口
|
||||
*/
|
||||
export interface NetConfig {
|
||||
/** 服务器地址 */
|
||||
serverUrl: string;
|
||||
|
||||
|
||||
/** 网络协议类型 默认 Http */
|
||||
protocolType?: NetProtocolType;
|
||||
|
||||
/** 超时时间(ms) 默认 30000 */
|
||||
timeout?: number;
|
||||
|
||||
|
||||
/** 是否自动重连 默认 true */
|
||||
autoReconnect?: boolean;
|
||||
|
||||
|
||||
/** 重连间隔(ms) 默认 3000 */
|
||||
reconnectInterval?: number;
|
||||
|
||||
|
||||
/** 最大重连次数 默认 5 */
|
||||
maxReconnectTimes?: number;
|
||||
|
||||
/** 是否使用JSON格式 默认 true */
|
||||
json?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认网络配置
|
||||
*/
|
||||
export const DefaultNetConfig: Partial<NetConfig> = {
|
||||
protocolType: NetProtocolType.Http,
|
||||
timeout: 30000,
|
||||
autoReconnect: true,
|
||||
reconnectInterval: 3000,
|
||||
maxReconnectTimes: 5
|
||||
maxReconnectTimes: 5,
|
||||
json: true
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user