Home » Docs » Server »
 

registerHookBadCmd

(since 1.0)



Catch all commands that are not registered

Description


string registerHookBadCmd ( function fn )

Register a function to handle all commands that are not already handled.

Parameters


fn
  • params - (object) The list of parameters sent by the client.
  • info - (object) Contains information about the client (see registerCmd for more informations)
  • raw - (string) The raw received

Examples


Log
Ape.registerHookBadCmd(function(params, info, raw){
	Ape.log("Bad RAW received ("+raw+").");
	//We return nothing so client will receive a BAD_CMD error
});

Forward all
Ape.registerHookBadCmd(function(params, info, raw) {
	if(!params.pipe) {
		return 0;//We return 0 so client will receive BAD_PARAMS error
	}
	var pipe = Ape.getPipe(params.pipe);
	if(!pipe) {
		return [109, 'UNKNOWN_PIPE']; //Client will receive UNKNOWN_PIPE error
	}
	pipe.sendRaw(raw, params, {from: info.user});
});

User notes


# No comment

Post a note


User notes may be edited or deleted, and usually a note is deleted because of the following reasons:
  • Bugs: Instead report a bug
  • Missing documentation: report that as a bug.
  • Support questions: See the community for available options.

In other words, do not ask questions within the user notes.

Note <b>,<u>,<i> HTML tags are allowed in the posts and the note formatting is preserved. URLs will be turned into clickable links, JavaScipt and C code blocks enclosed in the <source="javascript">JS Code</source> and <source="c">C Code</source> tags will be source highlighted automatically.