Case study:
EMG at Mblox (PDF)
Building and using a C plugin in EMG 6 Print
Monday, 02 June 2014

EMG plugins can be used to implement custom functionality in EMG with very little overhead. An EMG plugin can be implemented in C or Perl and will be called when a message is received and before and after it is sent by implementing different functions in the plugin.

The steps to build a C plugin are:

  • Download plugin-6.0.tar.gz
  • Extract it:
    gzip -d plugin-6.0.tar.gz
    tar xvf plugin-6.0.tar
  • Change directory and build it:
    cd plugin-6.0
    ./ myplugin

The sample "myplugin.c" includes a skeleton for a plugin. In order for the plugin to do something code needs to be added to "myplugin.c".

To get EMG to use the plugin you need to install and configure it.

  • Create /etc/emg/plugins
    mkdir /etc/emg/plugins
  • Copy the plugin
    cp /etc/emg/plugins
    chmod 755 /etc/emg/plugins/
  • Add a PLUGIN section to server.cfg
    PLUGIN myplugin <
  • Define that the plugin should be used on a connector
    CONNECTOR xyz <
  • Restart emgd

More information

EMG 6 - C Plugin API - Manual