Tips On Custom Command Server Implementation

A custom command handler must invoke the callback that is passed when it completes its operation.

DIarkis may have multiple command handlers assigned to a single command.

A command handler is passed a callback in its parameter, this callback enforces the order of handler execution when there are multiple handlers registered for the same command.

What you must keep in mind is that you MUST call the callback when a handler finishes its operation including error cases, otherwise the command operations may halt unexpectedly resulting in the loss of connection with clients.

server.HandleCommand(func(ver uint8, cmd uint16, payload []byte, user *user.User, next func(error)) {
  // you have your awesome handling code here!
  // when finished make sure to call next

Last updated