Class: base<CT>
Class: base<CT>
network.base
网络系统基类
Remarks
支持多实例
(心跳/断线重连)支持
网络消息接口事件化
支持消息潮
网络消息模拟
Type parameters
Name | Type |
---|---|
CT | extends codec_base = codec_base |
Hierarchy
↳
base
↳↳
websocket
↳↳
websocket_wx
Table of contents
Constructors
Properties
Accessors
Methods
- _reset_socket
- connect
- close
- _open
- _message
- _error
- _close
- _timer_send
- _timer_reconnect
- _cancel_reconnect
- _trigger_wait_task
- _start_heartbeat
- _set_write_sleep_b
- _event_restart
Constructors
constructor
• new base<CT
>(init_?
)
Type parameters
Name | Type |
---|---|
CT | extends codec_base = codec_base |
Parameters
Name | Type |
---|---|
init_? | Partial <init_config <CT >> |
Overrides
Defined in
assets/@framework/network/mk_network_base.ts:212
Properties
event
• event: event_target
<event_protocol
<CT
>>
网络事件
Defined in
assets/@framework/network/mk_network_base.ts:225
message
• message: message_event
<CT
>
消息事件
Defined in
assets/@framework/network/mk_network_base.ts:227
config
• config: Readonly
<init_config
<CT
>>
配置信息
Defined in
assets/@framework/network/mk_network_base.ts:229
_socket
• Protected
Abstract
_socket: any
socket
Defined in
assets/@framework/network/mk_network_base.ts:247
_log
• Protected
_log: logger
日志
Defined in
assets/@framework/network/mk_network_base.ts:249
_state
• Protected
_state: status
= mk_network_base_.status.closed
socket 状态
Defined in
assets/@framework/network/mk_network_base.ts:251
_addr_s
• Protected
_addr_s: string
地址
Defined in
assets/@framework/network/mk_network_base.ts:253
_write_as
• Protected
_write_as: any
[] = []
写入队列
Defined in
assets/@framework/network/mk_network_base.ts:260
Accessors
state
• get
state(): status
socket 状态
Returns
Defined in
assets/@framework/network/mk_network_base.ts:232
codec
• get
codec(): undefined
| CT
编解码器
Returns
undefined
| CT
Defined in
assets/@framework/network/mk_network_base.ts:237
• set
codec(value_
): void
Parameters
Name | Type |
---|---|
value_ | undefined | CT |
Returns
void
Defined in
assets/@framework/network/mk_network_base.ts:241
Methods
_reset_socket
▸ Protected
Abstract
_reset_socket(): void
重置 socket
Returns
void
Defined in
assets/@framework/network/mk_network_base.ts:281
connect
▸ connect(addr_s_
): void
连接
Parameters
Name | Type |
---|---|
addr_s_ | string |
Returns
void
Defined in
assets/@framework/network/mk_network_base.ts:284
close
▸ close(): void
断开
Returns
void
Defined in
assets/@framework/network/mk_network_base.ts:291
_open
▸ Protected
_open(event_
): void
socket 准备完成
Parameters
Name | Type |
---|---|
event_ | any |
Returns
void
Defined in
assets/@framework/network/mk_network_base.ts:351
_message
▸ Protected
_message(event_
): Promise
<void
>
socket 消息
Parameters
Name | Type |
---|---|
event_ | any |
Returns
Promise
<void
>
Defined in
assets/@framework/network/mk_network_base.ts:366
_error
▸ Protected
_error(event_
): void
socket 错误
Parameters
Name | Type |
---|---|
event_ | any |
Returns
void
Defined in
assets/@framework/network/mk_network_base.ts:391
_close
▸ Protected
_close(event_
): void
socket 关闭
Parameters
Name | Type |
---|---|
event_ | any |
Returns
void
Defined in
assets/@framework/network/mk_network_base.ts:398
_timer_send
▸ Protected
_timer_send(): Promise
<void
>
定时发送
Returns
Promise
<void
>
Defined in
assets/@framework/network/mk_network_base.ts:428
_timer_reconnect
▸ Protected
_timer_reconnect(): void
定时重连
Returns
void
Defined in
assets/@framework/network/mk_network_base.ts:447
_cancel_reconnect
▸ Protected
_cancel_reconnect(status_b_
): void
取消重连
Parameters
Name | Type | Description |
---|---|---|
status_b_ | boolean | 成功 | 失败 |
Returns
void
Defined in
assets/@framework/network/mk_network_base.ts:462
_trigger_wait_task
▸ Protected
_trigger_wait_task(data_
): void
触发等待任务
Parameters
Name | Type | Description |
---|---|---|
data_ | any | 收到的消息 |
Returns
void
Defined in
assets/@framework/network/mk_network_base.ts:485
_start_heartbeat
▸ Protected
_start_heartbeat(): void
初始化心跳
Returns
void
Defined in
assets/@framework/network/mk_network_base.ts:511
_set_write_sleep_b
▸ Protected
_set_write_sleep_b(value_b_
): void
Parameters
Name | Type |
---|---|
value_b_ | boolean |
Returns
void
Defined in
assets/@framework/network/mk_network_base.ts:576
_event_restart
▸ Protected
_event_restart(): void
Returns
void