public Torrent getChannelTorrent(String channelName) { try { Map genericMap = genericTorrent.writeToMap(); Map info = (Map) genericMap.get("info"); info.put("name", channelName.getBytes()); info.put("name.utf8", channelName.getBytes("UTF-8")); genericMap.put("info", info); // //// byte[] channelTorrent = // plugin_interface.getUtilities().getFormatters().bEncode(genericMap); byte[] channelTorrent = new FormattersImpl().bEncode(genericMap); // Torrent result = // plugin_interface.getTorrentManager().createFromBEncodedData(channelTorrent); Torrent result = TorrentManagerImpl.getSingleton().createFromBEncodedData(channelTorrent); result.setAnnounceURL(new URL("dht://chat.dht/announce")); return result; } catch (Exception e) { e.printStackTrace(); } return null; }
private Torrent loadTorrent(String res) { try { // InputStream is = this.getClass().getClassLoader().getResourceAsStream(res); // if (is != null) { // try { File file = new File(res); System.out.println("FileRef: " + file.exists()); return TorrentManagerImpl.getSingleton().createFromBEncodedFile(file); // return TorrentManagerImpl.getSingleton().createFromBEncodedInputStream(is); // return plugin_interface.getTorrentManager().createFromBEncodedInputStream(is); // } catch(Exception e) { // e.printStackTrace(); // return null; } catch (TorrentException ex) { Logger.getLogger(ChatPlugin.class.getName()).log(Level.SEVERE, null, ex); } // return TorrentManagerImpl.getSingleton().createFromBEncodedInputStream(is); // return plugin_interface.getTorrentManager().createFromBEncodedInputStream(is); // } catch(Exception e) { // e.printStackTrace(); return null; }
public TorrentManager getTorrentManager() { return (TorrentManagerImpl.getSingleton().specialise(this)); }