Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8684581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:20:37+00:00 2026-06-12T22:20:37+00:00

I am trying to do a plugin like: main process() { call plugin to

  • 0

I am trying to do a plugin like:

main process()
{
   call plugin to do something;
}

plugin()
{
   PART A: to encode a message, and send to other app;
   PART B: to decode a message, and call PART A to check whether we need to send more messages.
}

So, for PART B, it will be called automatically, when the reply returns. When I am in PARTB, I will return to PART A, but I am in PART A, I can’t directly call PART B, because it should be called when a reply returns, so how can I do a loop in async call? When I send a message, how to wait until the reply comes to PART B. Thanks for your suggesion.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:20:38+00:00Added an answer on June 12, 2026 at 10:20 pm

    This is up to your implementation of main process and design of your plugins for example I have something like this:

    struct message;
    typedef std::function<bool(message&)> message_handler;
    struct IMainProcess {
        virtual int add_listener( message_handler const& f ) = 0;
        virtual void remove_listener( int key ) = 0;
    };
    struct IPlugin {
        virtual bool initialize( IMainProcess* p ) = 0;
        virtual void shutdown() = 0;
    };
    
    struct MainProcess : IMainProcess {
        int key;
        std::map<int, message_handler > listeners;
        MainProcess() : key( 0 ) {}
        virtual int add_listener( message_handler const& f ) {
            int res = key++;
            listeners[key] = f;
        }
        virtual void remove_listener( int key ) {
            listeners.erase( key );
        }
    
        void message_received( message& m ) {
            // call all plugins that registered for incoming messages
            for( auto i = listeners.begin(); i != listeners.end(); i++ ) {
                if( !i->second(m) ) break;
            }
        }
    };
    int main() {
        MainProcess mp;
        // Load plugins from some location and initialize them
        std::vector<std::auto_ptr<IPlugin> > plugins;
        while( IPlugin* p = load_plugin() ) {
            std::auto_ptr<IPlugin> sp( p );
            if( p->initialize(&mp) ) plugins.push_back( sp );
        }
        while( message* msg = wait_for_message() ) {
            std::auto_ptr<message> smsg( msg );
            mp.message_received( *msg );
        }
        // end of operation
        for( auto i = plugins.begin(); i != plugins.end(); i++ ) {
            (*i)->shutdown();
        }
        return 0;
    }
    

    Now plugin can have any desired architecture and can also receive incoming messages!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to give my plugin callback functionality, and I'd like for it to
I am trying to using a jquery.validate.unotrusive.js plugin to dynamically created form fields like:
I am trying to use the maven-assembly plugin like so to build a zip
I am trying to call MavenCli from my OSGi plugin project. I have added
I am trying to build a basic plugin system like the kind you often
I'm new to Android, and I'm trying to do something simple like play a
I'm trying to create plugin importing posts to WordPress. Imported articles (XML) contain image-name
I am using the JQuery json plugin and trying to convert a custom object
Trying to work with Eclipse for Android (ADT plugin) development at my iMac (2.4Ghz,
Trying to create a generic video plugin for Expression Engine 2 where I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.