We’ve just pushed upgrades to the frostwire-jlibtorrent API that will allow developers to extend and interact the Bittorrent protocol at a lower level through the implementation of libtorrent plugins.
Before today, a libtorrent plugin developer had to code plugins in C++ and rebuild the libtorrent library binaries for the architectures on which the plugin was meant to be used.
We think that non-bittorrent higher level abstractions (e.g. Bitcoin+Bittorrent integration) that need to occur near the core of the bittorrent protocol can be more easily coded, tested and debugged in a language like Java, without having to touch nor recompile the libtorrent libraries.
Today we’ve made available a new portion of the frostwire-jlibtorrent API that allows you to do this without all the C++ development headaches, you just focus on your plugin logic, and your code will also be available in all platforms with the same .class files.
Here’s an example of a dummy libtorrent Plugin implemented in Java using frostwire-jlibtorrent
To create a Plugin all you need to do is extend the AbstractPlugin class, whose newTorrent method will ask you to provide a TorrentPlugin interface implementation, this is meant to be a plugin instance that takes care of what happens when a torrent is added to the libtorrent session.
We provide an AbstractTorrentPlugin class for you to extend and as you do this you may or may not need to provide your own implementation of the TorrentPlugin::newPeerConnection method, which is meant to return a PeerPlugin, a plugin instance that takes care of what happens for every Peer connection, where probably most of your plugin logic will occur. We also provide an AbstractPeerPlugin implementation that you can extend.
Once you have your plugin ready to go, you can add it to the session with session.addExtension(myPlugin) and all torrents added to the session will invoke hooks that could be handled by your plugin implementations.