chore: ensure connected_at field for connect/connack/disconnected event
This commit is contained in:
parent
d535d44845
commit
ad996afe47
|
@ -93,6 +93,7 @@ on_client_connect(ConnInfo = #{clientid := ClientId, username := Username, peern
|
||||||
, ipaddress => iolist_to_binary(ntoa(Peerhost))
|
, ipaddress => iolist_to_binary(ntoa(Peerhost))
|
||||||
, keepalive => maps:get(keepalive, ConnInfo)
|
, keepalive => maps:get(keepalive, ConnInfo)
|
||||||
, proto_ver => maps:get(proto_ver, ConnInfo)
|
, proto_ver => maps:get(proto_ver, ConnInfo)
|
||||||
|
, connected_at => maps:get(connected_at, ConnInfo)
|
||||||
},
|
},
|
||||||
send_http_request(ClientId, Params).
|
send_http_request(ClientId, Params).
|
||||||
|
|
||||||
|
@ -109,6 +110,7 @@ on_client_connack(ConnInfo = #{clientid := ClientId, username := Username, peern
|
||||||
, ipaddress => iolist_to_binary(ntoa(Peerhost))
|
, ipaddress => iolist_to_binary(ntoa(Peerhost))
|
||||||
, keepalive => maps:get(keepalive, ConnInfo)
|
, keepalive => maps:get(keepalive, ConnInfo)
|
||||||
, proto_ver => maps:get(proto_ver, ConnInfo)
|
, proto_ver => maps:get(proto_ver, ConnInfo)
|
||||||
|
, connected_at => maps:get(connected_at, ConnInfo)
|
||||||
, conn_ack => Rc
|
, conn_ack => Rc
|
||||||
},
|
},
|
||||||
send_http_request(ClientId, Params).
|
send_http_request(ClientId, Params).
|
||||||
|
@ -143,6 +145,7 @@ on_client_disconnected(#{clientid := ClientId, username := Username}, Reason, Co
|
||||||
, clientid => ClientId
|
, clientid => ClientId
|
||||||
, username => maybe(Username)
|
, username => maybe(Username)
|
||||||
, reason => stringfy(maybe(Reason))
|
, reason => stringfy(maybe(Reason))
|
||||||
|
, connected_at => maps:get(connected_at, ConnInfo)
|
||||||
, disconnected_at => maps:get(disconnected_at, ConnInfo, erlang:system_time(millisecond))
|
, disconnected_at => maps:get(disconnected_at, ConnInfo, erlang:system_time(millisecond))
|
||||||
},
|
},
|
||||||
send_http_request(ClientId, Params).
|
send_http_request(ClientId, Params).
|
||||||
|
|
|
@ -52,7 +52,8 @@ prop_client_connect() ->
|
||||||
username => maybe(maps:get(username, ConnInfo)),
|
username => maybe(maps:get(username, ConnInfo)),
|
||||||
ipaddress => peer2addr(maps:get(peername, ConnInfo)),
|
ipaddress => peer2addr(maps:get(peername, ConnInfo)),
|
||||||
keepalive => maps:get(keepalive, ConnInfo),
|
keepalive => maps:get(keepalive, ConnInfo),
|
||||||
proto_ver => maps:get(proto_ver, ConnInfo)
|
proto_ver => maps:get(proto_ver, ConnInfo),
|
||||||
|
connected_at => maps:get(connected_at, ConnInfo)
|
||||||
}),
|
}),
|
||||||
true
|
true
|
||||||
end).
|
end).
|
||||||
|
@ -71,6 +72,7 @@ prop_client_connack() ->
|
||||||
ipaddress => peer2addr(maps:get(peername, ConnInfo)),
|
ipaddress => peer2addr(maps:get(peername, ConnInfo)),
|
||||||
keepalive => maps:get(keepalive, ConnInfo),
|
keepalive => maps:get(keepalive, ConnInfo),
|
||||||
proto_ver => maps:get(proto_ver, ConnInfo),
|
proto_ver => maps:get(proto_ver, ConnInfo),
|
||||||
|
connected_at => maps:get(connected_at, ConnInfo),
|
||||||
conn_ack => Rc
|
conn_ack => Rc
|
||||||
}),
|
}),
|
||||||
true
|
true
|
||||||
|
@ -106,6 +108,7 @@ prop_client_disconnected() ->
|
||||||
node => stringfy(node()),
|
node => stringfy(node()),
|
||||||
clientid => maps:get(clientid, ClientInfo),
|
clientid => maps:get(clientid, ClientInfo),
|
||||||
username => maybe(maps:get(username, ClientInfo)),
|
username => maybe(maps:get(username, ClientInfo)),
|
||||||
|
connected_at => maps:get(connected_at, ConnInfo),
|
||||||
disconnected_at => maps:get(disconnected_at, ConnInfo),
|
disconnected_at => maps:get(disconnected_at, ConnInfo),
|
||||||
reason => stringfy(Reason)
|
reason => stringfy(Reason)
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -57,8 +57,7 @@ on_client_connected(ClientInfo = #{clientid := ClientId}, ConnInfo, Env) ->
|
||||||
connack => 0, %% XXX: connack will be removed in 5.0
|
connack => 0, %% XXX: connack will be removed in 5.0
|
||||||
keepalive => maps:get(keepalive, ConnInfo, 0),
|
keepalive => maps:get(keepalive, ConnInfo, 0),
|
||||||
clean_start => maps:get(clean_start, ConnInfo, true),
|
clean_start => maps:get(clean_start, ConnInfo, true),
|
||||||
expiry_interval => maps:get(expiry_interval, ConnInfo, 0),
|
expiry_interval => maps:get(expiry_interval, ConnInfo, 0)
|
||||||
connected_at => maps:get(connected_at, ConnInfo)
|
|
||||||
},
|
},
|
||||||
case emqx_json:safe_encode(NPresence) of
|
case emqx_json:safe_encode(NPresence) of
|
||||||
{ok, Payload} ->
|
{ok, Payload} ->
|
||||||
|
@ -95,7 +94,8 @@ common_infos(
|
||||||
sockport := SockPort
|
sockport := SockPort
|
||||||
},
|
},
|
||||||
_ConnInfo = #{proto_name := ProtoName,
|
_ConnInfo = #{proto_name := ProtoName,
|
||||||
proto_ver := ProtoVer
|
proto_ver := ProtoVer,
|
||||||
|
connected_at := ConnectedAt
|
||||||
}) ->
|
}) ->
|
||||||
#{clientid => ClientId,
|
#{clientid => ClientId,
|
||||||
username => Username,
|
username => Username,
|
||||||
|
@ -103,6 +103,7 @@ common_infos(
|
||||||
sockport => SockPort,
|
sockport => SockPort,
|
||||||
proto_name => ProtoName,
|
proto_name => ProtoName,
|
||||||
proto_ver => ProtoVer,
|
proto_ver => ProtoVer,
|
||||||
|
connected_at => ConnectedAt,
|
||||||
ts => erlang:system_time(millisecond)
|
ts => erlang:system_time(millisecond)
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue