Skip to content
rolandvl edited this page May 24, 2015 · 4 revisions

simple batch, returning a string

server side code


function __helloworld(params, customData, mod) {
	"use strict;"
	// don't edit above this line // must be on line 3
  mod.debug(JSON.stringify(params));
  return { "message" : params.request.text + " world!" }
}

Invoking mod.debug allows us to print some text in the BackOffice console, right after the source code editor of the batch, section called "Logs". Each time the batch will be called, refresh this view to get the logs. Could be useful to debug your script.

Regarding our setup, the log must look like {"domain":"com.company.game.secret","user_id":"xxxxxxx","request":{"text":"hello"}}

In production environment mod.debug does nothing!

client invocation

CHJSON config;
config.Put("name", "helloworld");
CHJSON params;
params.Put("text", "hello");
CUserManager::Instance()->Batch(MakeResultHandler(this, &Handle), &config, &params);

results

{
"message" :  "hello world!";
...
}

Clone this wiki locally