/Testenviro/run Torrent client/testTalkToJava.erl~
Unknown | 38 lines | 24 code | 14 blank | 0 comment | 0 complexity | d33981dbc41db04957c9ab7207c6b6a8 MD5 | raw file
1-module(testTalkToJava). 2-export([start/0]). 3%-include("defs.hrl"). 4 5start() -> 6 ComputerName = net_adm:localhost(), 7 NodeName = "javaNode@" ++ ComputerName, 8 NodeAtom = list_to_atom(NodeName), 9 timer:sleep(7000), 10 {mailbox, NodeAtom} ! {self(), "startconnection"}, 11 %%blackboard ! {register_static, gui}, 12 %%blackboard ! {subscribe, gui, [torrent_info, torrent_status, tracker_info, seeders, leechers, uploaded, downloaded, left, torrent_size, file_name, pieces, download_speed, upload_speed]}, 13 rec(NodeAtom, now()). 14 15 16rec(NodeAtom, {_,_,Value}) -> 17TorrentId = "torrent1", 18 19 {mailbox2, NodeAtom} ! {self(), TorrentId, 0, integer_to_list(Value*2)}, 20 21 {mailbox2, NodeAtom} ! {self(), TorrentId, 1, integer_to_list(Value*3)}, 22 23 {mailbox2, NodeAtom} ! {self(), TorrentId, 3, integer_to_list(Value*5)}, 24 25 {mailbox2, NodeAtom} ! {self(), TorrentId, 4, integer_to_list(Value*4)}, 26 27 {mailbox2, NodeAtom} ! {self(), TorrentId, 5, integer_to_list(Value+200)}, 28 29 {mailbox2, NodeAtom} ! {self(), TorrentId, 6, integer_to_list(Value+300)}, 30 31 {mailbox2, NodeAtom} ! {self(), TorrentId, 7, integer_to_list(Value+200)}, 32 33 {mailbox2, NodeAtom} ! {self(), TorrentId, 8, integer_to_list(Value-200)}, 34 35 {mailbox2, NodeAtom} ! {self(), TorrentId, 9, "Torrent finished downloading"}, 36 37 rec(NodeAtom, now()). 38