Handle HAVE_ALL and HAVE_NONE. Cleanup the BITFIELD message.
[etorrent.git] / lib / etorrent-1.0 / src / etorrent_t_pool_sup.erl
blob1c9a9a0547e1e0fec5c1c384f0bf22e91a1802a7
1 %%%-------------------------------------------------------------------
2 %%% File : etorrent_t_pool_sup.erl
3 %%% Author : Jesper Louis Andersen <jesper.louis.andersen@gmail.com>
4 %%% License : See COPYING
5 %%% Description : Supervisor for the pool of torrents
6 %%%
7 %%% Created : 13 Jul 2007 by
8 %%% Jesper Louis Andersen <jesper.louis.andersen@gmail.com>
9 %%%-------------------------------------------------------------------
10 -module(etorrent_t_pool_sup).
12 -behaviour(supervisor).
14 %% API
15 -export([start_link/0, add_torrent/3, stop_torrent/1]).
17 %% Supervisor callbacks
18 -export([init/1]).
20 -define(SERVER, ?MODULE).
22 %%====================================================================
23 %% API functions
24 %%====================================================================
25 start_link() ->
26 supervisor:start_link({local, ?SERVER}, ?MODULE, []).
28 add_torrent(File, Local_PeerId, Id) ->
29 Torrent = {File,
30 {etorrent_t_sup, start_link, [File, Local_PeerId, Id]},
31 transient, infinity, supervisor, [etorrent_t_sup]},
32 supervisor:start_child(?SERVER, Torrent).
34 stop_torrent(File) ->
35 supervisor:terminate_child(?SERVER, File),
36 supervisor:delete_child(?SERVER, File).
38 %%====================================================================
39 %% Supervisor callbacks
40 %%====================================================================
41 init([]) ->
42 {ok,{{one_for_one, 5, 60}, []}}.
44 %%====================================================================
45 %% Internal functions
46 %%====================================================================