Skip to content
jorishermans edited this page Dec 26, 2014 · 1 revision

You can validate your data packages serverside.

This can be done by defining a validate method:

forceServer.publish("hunters", cargo, validate: (CargoPackage fcp, Sender sender) {
        // validate your data
});

CargoPackage has the following members:

  • wsId: the id of the socket
  • collection: the name of the collection
  • key: the key of the data that needs to be stored (can be null sometimes)
  • profile: info about the logged in user, profile info can be stored here (can be null sometimes)
  • json (this is the data package that needs to be saved in the persistent layer within cargo)
  • params: when you want to filter certain data (ex. {checked: true} only checked data will be returned)
  • action: data action that is going to happen

All the actions that are possible SUBSCRIBE ADD SET UPDATE REMOVE CANCEL

With fcp.cancel() you can cancel a data transaction. For example when an url is not a valid url we are not going to store this url in the database (mongodb, file, memory, ...)

if (!hunt.url.startsWith("http")) {
     fcp.cancel();
            
     sender.reply("notify", "url not correct!");
}
Clone this wiki locally