-module(emqx_tcp_protocol).
-export([logger_header/0]).
-include("emqx_tcp/include/emqx_tcp.hrl").
-include("emqx/include/emqx.hrl").
-include("/emqx/include/logger.hrl").
-import(proplists, [get_value/2]).
-import(emqx_misc, [maybe_apply/2]).
-export([init/2,received/2,
deliver/2,terminate/2,maybe_gc_and_check_oom/2]).
-export([info/1, client_id/1, stats/1]).
-record(pstate,
{peername,
sockname,
peercert,
client_id,
username,
keepalive,
sendfun, %% 发送函数
conn_pid, %% 连接进程ID
connected = false,
up_topic, %% 上行主题
dn_topic, %% 下行主题
proto_ver,%% 协议版本
conn_mod, %% 连接模块
connected_at, %% 连接时间
gc_state, %% gc状态
recv_stats, %% 接收统计
send_stats}). %% 发送统计
-vsn("4.2.1").
%% 初始化
init(SocketOpts = #{sockname := Sockname,peername := Peername, peercer