/Testenviro/run Torrent client/testTalkToJava.erl~

http://github.com/anonymous-admin/anonymous · 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. start() ->
  5. ComputerName = net_adm:localhost(),
  6. NodeName = "javaNode@" ++ ComputerName,
  7. NodeAtom = list_to_atom(NodeName),
  8. timer:sleep(7000),
  9. {mailbox, NodeAtom} ! {self(), "startconnection"},
  10. %%blackboard ! {register_static, gui},
  11. %%blackboard ! {subscribe, gui, [torrent_info, torrent_status, tracker_info, seeders, leechers, uploaded, downloaded, left, torrent_size, file_name, pieces, download_speed, upload_speed]},
  12. rec(NodeAtom, now()).
  13. rec(NodeAtom, {_,_,Value}) ->
  14. TorrentId = "torrent1",
  15. {mailbox2, NodeAtom} ! {self(), TorrentId, 0, integer_to_list(Value*2)},
  16. {mailbox2, NodeAtom} ! {self(), TorrentId, 1, integer_to_list(Value*3)},
  17. {mailbox2, NodeAtom} ! {self(), TorrentId, 3, integer_to_list(Value*5)},
  18. {mailbox2, NodeAtom} ! {self(), TorrentId, 4, integer_to_list(Value*4)},
  19. {mailbox2, NodeAtom} ! {self(), TorrentId, 5, integer_to_list(Value+200)},
  20. {mailbox2, NodeAtom} ! {self(), TorrentId, 6, integer_to_list(Value+300)},
  21. {mailbox2, NodeAtom} ! {self(), TorrentId, 7, integer_to_list(Value+200)},
  22. {mailbox2, NodeAtom} ! {self(), TorrentId, 8, integer_to_list(Value-200)},
  23. {mailbox2, NodeAtom} ! {self(), TorrentId, 9, "Torrent finished downloading"},
  24. rec(NodeAtom, now()).