fix
This commit is contained in:
parent
a44c898c4f
commit
b0440db7f5
@ -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}) ->
|
||||
%% 重新加载主机信息
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user