forked from gotthardp/gen_coap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coap_channel_sup_sup.erl
33 lines (25 loc) · 934 Bytes
/
coap_channel_sup_sup.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
%
% The contents of this file are subject to the Mozilla Public License
% Version 1.1 (the "License"); you may not use this file except in
% compliance with the License. You may obtain a copy of the License at
% http:https://www.mozilla.org/MPL/
%
% Copyright (c) 2015 Petr Gotthard <[email protected]>
%
% stores one channel handler per endpoint
% when communication ceases the respective channel exits normally
-module(coap_channel_sup_sup).
-behaviour(supervisor).
-export([start_link/0, start_channel/2, delete_channel/2, init/1]).
start_link() ->
supervisor:start_link(?MODULE, []).
start_channel(SupPid, ChId) ->
supervisor:start_child(SupPid,
{ChId,
{coap_channel_sup, start_link, [self(), ChId]},
temporary, infinity, supervisor, []}).
delete_channel(SupPid, ChId) ->
supervisor:terminate_child(SupPid, ChId).
init([]) ->
{ok, {{one_for_one, 0, 1}, []}}.
% end of file