This commit is contained in:
anlicheng 2023-08-09 16:35:42 +08:00
parent a44c898c4f
commit b0440db7f5

View File

@ -168,21 +168,22 @@ handle_event({call, From}, {rsa_encode, CommandType, PlainText}, session, State
handle_event({call, From}, {rsa_encode, _, _}, _, State) ->
{keep_state, State, [{reply, From, {error, <<"会话未建立"/utf8>>}}]};
%%
handle_event({call, From}, {publish_message, ReceiverPid, CommandType, Command}, session, State = #state{aes = AES, channel_pid = ChannelPid}) ->
SendCommand = case Command of
{aes, Command0} ->
iot_cipher_aes:encrypt(AES, Command0);
Command0 ->
Command0
end,
%% ,
handle_event({call, From}, {publish_message, ReceiverPid, CommandType, {aes, Command0}}, session, State = #state{aes = AES, channel_pid = ChannelPid}) ->
Command = iot_cipher_aes:encrypt(AES, Command0),
%% websocket发送请求
Ref = ws_channel:publish(ChannelPid, ReceiverPid, <<CommandType:8, SendCommand/binary>>),
Ref = ws_channel:publish(ChannelPid, ReceiverPid, <<CommandType:8, Command/binary>>),
{keep_state, State, [{reply, From, {ok, Ref}}]};
handle_event({call, From}, {publish_message, ReceiverPid, CommandType, Command}, _, State = #state{channel_pid = ChannelPid}) when is_binary(Command) ->
%% websocket发送请求
Ref = ws_channel:publish(ChannelPid, ReceiverPid, <<CommandType:8, Command/binary>>),
{keep_state, State, [{reply, From, {ok, Ref}}]};
handle_event({call, From}, {publish_message, _, _, _}, _, State) ->
{keep_state, State, [{reply, From, {error, <<"会话未建立"/utf8>>}}]};
{keep_state, State, [{reply, From, {error, <<"命令类型错误,发送命令失败"/utf8>>}}]};
handle_event({call, From}, reload, StateName, State = #state{uuid = UUID}) ->
%%