Naming convention for message?

  • Anime Lovers

    Is there any standard naming convention for message?

    I did some search and find out some patterns below:

    1. nodebb plugin - event:{type} eg. event:user_status_change
    2. custom plugin - {pluginName}:{type} eg. nodebb-plugin-myplugin:data_change

    Any official comment on this? Thanks!

  • Global Moderator Plugin & Theme Dev

    @Bruce-Lee something like

    var PluginSockets = require.main.require('./src/');
    PluginSockets.yourPlugin = {};
    PluginSockets.yourPlugin.whatever = function (a, b, c) {};

    On the server side equates to

    socket.emit('plugins.yourPlugin.whatever', a, b, c);

    On the client.

  • NodeBB Admin

    Actually it's

    //server side
    PluginSockets.yourPlugin.whatever = function (socket, data, callback) {
    //socket.uid - uid of the user making the call or 0 for guests
    //data - data passed from the client
    //callback - notify client when you are done, pass err as first param
    //client side
    socket.emit('plugins.yourPlugin.whatever', {foo: 'bar'}, function(err, data) {
         if (err) {
  • Anime Lovers

    Thanks @baris and @PitaJ for the nice info, I will try it out.

Suggested Topics

| | |

© 2014 – 2022 NodeBB, Inc. — Made in Canada.