fix ssl channel
This commit is contained in:
parent
5511ed6be2
commit
2ff3f3b2c1
@ -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,
|
||||
|
||||
@ -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};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user