fix(gw-stomp): unify the hearbeat type name

This commit is contained in:
JianBo He 2021-07-26 10:06:56 +08:00
parent c36cdf9682
commit a116c0afd1
3 changed files with 8 additions and 6 deletions

View File

@ -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,

View File

@ -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.

View File

@ -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(),