This commit is contained in:
anlicheng 2023-06-19 14:45:13 +08:00
parent 373c0748cf
commit 760287e78a

View File

@ -178,6 +178,12 @@ handle_event({call, From}, has_session, StateName, State) ->
HasSession = (StateName =:= session) orelse false,
{keep_state, State, [{reply, From, HasSession}]};
handle_event({call, From}, {make_assoc, ReceiverPid}, _, State = #state{uuid = UUID, increment_id = IncrementId, assoc_map = AssocMap}) ->
BinIncrementId = erlang:integer_to_binary(IncrementId),
Assoc = <<UUID/binary, ":assoc:", BinIncrementId/binary>>,
{keep_state, State#state{assoc_map = maps:put(Assoc, ReceiverPid, AssocMap), increment_id = IncrementId + 1}, [{reply, From, {ok, Assoc}}]};
%% rsa加密
handle_event({call, From}, {rsa_encode, CommandType, PlainText}, session, State = #state{pub_key = PubKey}) ->
Reply = iot_cipher_rsa:encode(PlainText, PubKey),