Coder Social home page Coder Social logo

Comments (8)

gubatron avatar gubatron commented on August 18, 2024

cc: @aldenml

from frostwire-jlibtorrent.

aldenml avatar aldenml commented on August 18, 2024

I removed the support for now and to explain:

The plugins torrent_plugin and peer_plugin are added by default and the only reason having the plugin interface exposed is if you want to create a plugin from java to plug in libtorrent. But that is impossible in the current form, because there is no such thing like inheriting a class in java and then passing it to the native world.

In the future and if necessary, we could create the mechanisms to create plugins from java.

No plans for now.

from frostwire-jlibtorrent.

gubatron avatar gubatron commented on August 18, 2024

@aldenml does the issue of not being able to use it in the current form happen because of how that method interface takes a function as a parameter?

I see that every other method which receives a boost::function as a parameter is also gone.

$ grep "(boost::function" *.cpp
alert_manager.cpp:  void alert_manager::set_dispatch_function(boost::function<void(std::auto_ptr<alert>)> const& fun)
alert_manager.cpp:  void dispatch_alert(boost::function<void(alert const&)> dispatcher
connection_queue.cpp:   void connection_queue::enqueue(boost::function<void(int)> const& on_connect
session.cpp:    void session::add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> ext)
session.cpp:    void session::set_alert_dispatch(boost::function<void(std::auto_ptr<alert>)> const& fun)
session_impl.cpp:   void session_impl::set_alert_dispatch(boost::function<void(std::auto_ptr<alert>)> const& fun)
torrent.cpp:    void torrent::add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> const& ext

all of those you won't find on the swig interfaces.

from frostwire-jlibtorrent.

aldenml avatar aldenml commented on August 18, 2024

No, passing a boost::function parameters is another issue. This one is related to the impossibility of inherit from plugin in (swig)-java and pass the object to the native side.

from frostwire-jlibtorrent.

gubatron avatar gubatron commented on August 18, 2024

@bedeho was thinking of how to help you during lunch.

For now I believe it's really hard to do this on the frostwire-jlibtorrent side as there are limitations on how to deal with boost::function on the Java side.

I think your path of action should be the following: since you're doing something so level which is basically create an extension to libtorrent (and not just use it as a client, which is mainly the purpose of frostwire-jlibtorrent), you ought to do the extension in C++, and then continue the rest of the work in java using the library.

Take a look at libtorrent.i, around line 730, and once you have your extension ready, you should do something along these lines:

    void add_lt_trackers_extension() {
        $self->add_extension(&libtorrent::create_lt_trackers_plugin);
    }

    void add_smart_ban_extension() {
         $self->add_extension(&libtorrent::create_smart_ban_plugin);
    }

   void add_bedeho_extension() {
        $self->add_extension(&bedeho::create_my_extension_plugin);
   }

and then use the java add_bedeho_extension() function to activate it when you're starting the jlibtorrent session.

I took a brief look at what's implied with opening up the add_extension function to Session, and it becomes a huge mess on the java side because of all the stuff that comes from boost, which doesn't map very well from C++ to Java due to genericity.

please correct me if I'm wrong @aldenml

from frostwire-jlibtorrent.

bedeho avatar bedeho commented on August 18, 2024

Thank you gubatron, yes, I also concluded that I have to make the extension itself in C++.

Before reading this, I had resigned to doing the libtorrent client in C++ as well, and then try to make some light weight bindings for bitcoinj instead, but I will give this approach a try as well.
The challenge would be to communicate with the extension itself from the Java jlibtorrent client. It is easy for the extension to send messages to the client, by simply extending the alert class as the document suggests, but the other way, that is how the client can control the extension, is then more difficult. Perhaps your swig code can create some bindings for this as well.

I think your main conclusion is right either way, jlibtorrent is best for building a traditional client, not extensions - which is actually quite reasonable, given that libtorrent has most
BEPs one could want directly implemented.

from frostwire-jlibtorrent.

gubatron avatar gubatron commented on August 18, 2024

you are spot on, you can extend the alert classes (I think @aldenml did some remarkably creative work there with reflection on the java side and preprocessor on the C++/Swig side you should take a look at if you go with that route, see CAST_ALERT_METHOD), or just add new swig entry points and extend the api for your fork.

I'd try to stay away from coding the whole thing in C++, as you can imagine I'm a bit biased towards working mostly on the java side ;)

from frostwire-jlibtorrent.

bedeho avatar bedeho commented on August 18, 2024

Thanks, I prefer Java as well!

from frostwire-jlibtorrent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.