diff --git a/apps/emqx_gateway/src/stomp/emqx_stomp_channel.erl b/apps/emqx_gateway/src/stomp/emqx_stomp_channel.erl index 75e48b07b..e0fb4b82e 100644 --- a/apps/emqx_gateway/src/stomp/emqx_stomp_channel.erl +++ b/apps/emqx_gateway/src/stomp/emqx_stomp_channel.erl @@ -758,7 +758,7 @@ handle_timeout(_TRef, {keepalive_send, NewVal}, {error, timeout} -> NHrtBt = emqx_stomp_heartbeat:reset(outgoing, NewVal, HrtBt), NChannel = Channel#channel{heartbeat = NHrtBt}, - {ok, {outgoing, emqx_stomp_frame:make(heartbeat)}, + {ok, {outgoing, emqx_stomp_frame:make(?CMD_HEARTBEAT)}, reset_timer(outgoing_timer, NChannel)}; {ok, NHrtBt} -> {ok, reset_timer(outgoing_timer, diff --git a/apps/emqx_gateway/src/stomp/emqx_stomp_frame.erl b/apps/emqx_gateway/src/stomp/emqx_stomp_frame.erl index fd05abfe6..2b511b57a 100644 --- a/apps/emqx_gateway/src/stomp/emqx_stomp_frame.erl +++ b/apps/emqx_gateway/src/stomp/emqx_stomp_frame.erl @@ -242,7 +242,7 @@ unescape(_Ch) -> error(cannnot_unescape). serialize_opts() -> #{}. -serialize_pkt(#stomp_frame{command = heartbeat}, _SerializeOpts) -> +serialize_pkt(#stomp_frame{command = ?CMD_HEARTBEAT}, _SerializeOpts) -> <<$\n>>; serialize_pkt(#stomp_frame{command = Cmd, headers = Headers, body = Body}, @@ -279,8 +279,8 @@ new_state(#parser_state{limit = Limit}) -> %% @doc Make a frame -make(heartbeat) -> - #stomp_frame{command = heartbeat}. +make(?CMD_HEARTBEAT) -> + #stomp_frame{command = ?CMD_HEARTBEAT}. make(<<"CONNECTED">>, Headers) -> #stomp_frame{command = <<"CONNECTED">>, @@ -317,4 +317,5 @@ type(?CMD_DISCONNECT) -> disconnect; type(?CMD_CONNECTED) -> connected; type(?CMD_MESSAGE) -> message; type(?CMD_RECEIPT) -> receipt; -type(?CMD_ERROR) -> error. +type(?CMD_ERROR) -> error; +type(?CMD_HEARTBEAT) -> heartbeat. diff --git a/apps/emqx_gateway/src/stomp/include/emqx_stomp.hrl b/apps/emqx_gateway/src/stomp/include/emqx_stomp.hrl index 9976f1da7..280c3e347 100644 --- a/apps/emqx_gateway/src/stomp/include/emqx_stomp.hrl +++ b/apps/emqx_gateway/src/stomp/include/emqx_stomp.hrl @@ -43,6 +43,7 @@ -define(CMD_MESSAGE, <<"MESSAGE">>). -define(CMD_RECEIPT, <<"RECEIPT">>). -define(CMD_ERROR, <<"ERROR">>). +-define(CMD_HEARTBEAT, <<"HEARTBEAT">>). %-type client_command() :: ?CMD_SEND | ?CMD_SUBSCRIBE | ?CMD_UNSUBSCRIBE % | ?CMD_BEGIN | ?CMD_COMMIT | ?CMD_ABORT | ?CMD_ACK @@ -53,7 +54,7 @@ %-type server_command() :: ?CMD_CONNECTED | ?CMD_MESSAGE | ?CMD_RECEIPT % | ?CMD_ERROR. --type server_command() :: binary() | heartbeat. +-type server_command() :: binary(). -record(stomp_frame, { command :: client_command() | server_command(),