Module: server/filter

server/filter

When you want to filter certain outgoing mesages, add a logger for them or something similar, this is the right module. To define your own filter you just have to add your own filter function to this Module. After this can use the SessionOptions the define the filter chain for your newly created session.
Source:

Examples

// on server side:
filterModule = require('multi/server/filter');

// some example filters

filterModule.changeMessageFilter = function (message, fromSocket) {
  message.myAttribute = 42;
  delete message.myOtherAttribute;
};

// Return true to reject the message. In this case it doesn't get send.
filterModule.rejectVolatileFilter = function (message, fromSocket) {
  if (message.volatile) {
    return true;
  }
};

filterModule.logger = function (message, fromSocket) {
  console.log('outgoing message:', message.name);
};
// on client side:
var sessionOptions = {
  filter: ['changeMessageFilter', 'rejectVolatileFilter', 'logger']
};
multi.createSession(sessionOptions);

Methods

<static> loggingFilter(message, fromSocket)

A simple logger for outgoing messages.
Parameters:
Name Type Description
message
fromSocket
Source: