跳至主要內容

Class: base<CT>

muzzik大约 2 分钟

index / network / base

Class: base<CT>

network.base

网络系统基类

Remarks

  • 支持多实例

  • (心跳/断线重连)支持

  • 网络消息接口事件化

  • 支持消息潮

  • 网络消息模拟

Type parameters

NameType
CTextends codec_base = codec_base

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new base<CT>(init_?)

Type parameters

NameType
CTextends codec_base = codec_base

Parameters

NameType
init_?Partial<init_config<CT>>

Overrides

instance_base.constructor

Defined in

assets/@framework/network/mk_network_base.ts:212open in new window

Properties

event

event: event_target<event_protocol<CT>>

网络事件

Defined in

assets/@framework/network/mk_network_base.ts:225open in new window


message

message: message_event<CT>

消息事件

Defined in

assets/@framework/network/mk_network_base.ts:227open in new window


config

config: Readonly<init_config<CT>>

配置信息

Defined in

assets/@framework/network/mk_network_base.ts:229open in new window


_socket

Protected Abstract _socket: any

socket

Defined in

assets/@framework/network/mk_network_base.ts:247open in new window


_log

Protected _log: logger

日志

Defined in

assets/@framework/network/mk_network_base.ts:249open in new window


_state

Protected _state: status = mk_network_base_.status.closed

socket 状态

Defined in

assets/@framework/network/mk_network_base.ts:251open in new window


_addr_s

Protected _addr_s: string

地址

Defined in

assets/@framework/network/mk_network_base.ts:253open in new window


_write_as

Protected _write_as: any[] = []

写入队列

Defined in

assets/@framework/network/mk_network_base.ts:260open in new window

Accessors

state

get state(): status

socket 状态

Returns

status

Defined in

assets/@framework/network/mk_network_base.ts:232open in new window


codec

get codec(): undefined | CT

编解码器

Returns

undefined | CT

Defined in

assets/@framework/network/mk_network_base.ts:237open in new window

set codec(value_): void

Parameters

NameType
value_undefined | CT

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:241open in new window

Methods

_reset_socket

Protected Abstract _reset_socket(): void

重置 socket

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:281open in new window


connect

connect(addr_s_): void

连接

Parameters

NameType
addr_s_string

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:284open in new window


close

close(): void

断开

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:291open in new window


_open

Protected _open(event_): void

socket 准备完成

Parameters

NameType
event_any

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:351open in new window


_message

Protected _message(event_): Promise<void>

socket 消息

Parameters

NameType
event_any

Returns

Promise<void>

Defined in

assets/@framework/network/mk_network_base.ts:366open in new window


_error

Protected _error(event_): void

socket 错误

Parameters

NameType
event_any

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:391open in new window


_close

Protected _close(event_): void

socket 关闭

Parameters

NameType
event_any

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:398open in new window


_timer_send

Protected _timer_send(): Promise<void>

定时发送

Returns

Promise<void>

Defined in

assets/@framework/network/mk_network_base.ts:428open in new window


_timer_reconnect

Protected _timer_reconnect(): void

定时重连

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:447open in new window


_cancel_reconnect

Protected _cancel_reconnect(status_b_): void

取消重连

Parameters

NameTypeDescription
status_b_boolean成功 | 失败

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:462open in new window


_trigger_wait_task

Protected _trigger_wait_task(data_): void

触发等待任务

Parameters

NameTypeDescription
data_any收到的消息

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:485open in new window


_start_heartbeat

Protected _start_heartbeat(): void

初始化心跳

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:511open in new window


_set_write_sleep_b

Protected _set_write_sleep_b(value_b_): void

Parameters

NameType
value_b_boolean

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:576open in new window


_event_restart

Protected _event_restart(): void

Returns

void

Defined in

assets/@framework/network/mk_network_base.ts:594open in new window

📣 觉得很赞?分享给你的朋友吧!