How to design a C++ plugin framework which can support javascript plugin
<p>I'm trying to design a plugin system for an IM application using C++. The IM app is implemented using C++, too. The plugin system must support javascript plugins. </p>

<p>These plugins can interact with the IM app, for example, third party developers could implement a github-robot-plugin which can send wenbhook messages to the IM app whenever his/her project on github has any change(maybe it looks a little like Slack except for Slack is not a C++ app).  </p>

<p>I've read an article <a href="http://www.drdobbs.com/cpp/building-your-own-plugin-framework-part/204202899?pgno=1">Building Your Own Plugin Framework</a> in which a very simple but complete plugin framework is implemented. It designed a plugin manager to manager the registration, creation and destroy of any plugin. What is the most important thing I've learned from this article is that each plugin is essentially an interface.</p>

<p>I've implemented a bridge class which can let the javascript interact with C++. The javascript program could supply the command and some parameters and call C++ to do some logic actions though the methods provided by the bridge class. For example, with the javascript plugin, the third party developer has to provide some html resources. If a button called "save your github account info" in the html is clicked, the javascript would send a command called "save_account_info" to the bridge and C++ would save your github account info to local database. </p>

<p>I'm not very sure whether it is a good idea to provide an interface as following that the third developer must implement if they want to make a plugin:</p>

<pre><code>class IPlugin {
 public:
  virtual std::string bridge_call(std::string cmd, Json params) = 0;
};

class SomePlugin : public IPlugin {
 public:
  virtual std::string bridge_call(std::string cmd, Json params) {
    if (cmd == "some_command_1") {
      // do logic1
    } else if (cmd == "some_command_2") {
      // do logic2
    }
  }
};
</code></pre>

<p>Any suggestion is very appreciated.</p>