fix ssl channel

This commit is contained in:
anlicheng 2026-04-24 16:17:03 +08:00
parent 5511ed6be2
commit 2ff3f3b2c1
2 changed files with 22 additions and 20 deletions

View File

@ -266,7 +266,9 @@ handle_event({call, From}, {activate, false}, _, State = #state{uuid = UUID, cha
{next_state, ?STATE_DENIED, State#state{channel_pid = undefined, has_session = false}, [{reply, From, ok}]};
%% channel
handle_event({call, From}, {attach_channel, ChannelPid}, StateName, State = #state{uuid = UUID, channel_pid = undefined}) ->
handle_event({call, From}, {attach_channel, ChannelPid}, StateName, State = #state{uuid = UUID, channel_pid = OldChannelPid}) ->
case OldChannelPid == undefined orelse OldChannelPid =:= ChannelPid of
true ->
case StateName of
?STATE_ACTIVATED ->
erlang:monitor(process, ChannelPid),
@ -280,10 +282,10 @@ handle_event({call, From}, {attach_channel, ChannelPid}, StateName, State = #sta
erlang:monitor(process, ChannelPid),
{keep_state, State#state{channel_pid = ChannelPid}, [{reply, From, {denied, <<"host inactivated">>}}]}
end;
%% channel
handle_event({call, From}, {attach_channel, _}, _, State = #state{uuid = UUID, channel_pid = OldChannelPid}) ->
false ->
logger:notice("[iot_host] attach_channel host_id uuid: ~p, old channel exists: ~p", [UUID, OldChannelPid]),
{keep_state, State, [{reply, From, {error, <<"channel existed">>}}]};
{keep_state, State, [{reply, From, {error, <<"channel existed">>}}]}
end;
%%
handle_event(cast, {handle, {data, RouteKey, MetricBin}}, ?STATE_ACTIVATED,

View File

@ -58,7 +58,7 @@ activate(Pid, Auth) when is_pid(Pid), is_boolean(Auth) ->
Command = #'CastFrame.Command'{
command = {auth, #'CastFrame.Command.Authorization'{cmd = Cmd}}
},
command(Pid, Command).
gen_server:cast(Pid, {command, Command}).
-spec container_call(Pid :: pid(), ReceiverPid :: pid(), Request :: message_pb:'ContainerRequest'()) -> Ref :: reference().
container_call(Pid, ReceiverPid, Request) when is_pid(Pid), is_pid(ReceiverPid), is_record(Request, 'ContainerRequest') ->
@ -114,7 +114,7 @@ handle_cast({pub, Topic, Qos, Content}, State = #state{transport = Transport, so
%% Command消息
handle_cast({command, Command}, State = #state{transport = Transport, socket = Socket}) ->
Encoded = message_pb:encode_msg(#'CastFrame'{
body = Command
body = {command, Command}
}),
Transport:send(Socket, <<?FRAME_CAST, Encoded/binary>>),
{noreply, State};