red-worker: Reduce casts needed in dispatcher handlers
Use a template to deduct type and avoid casts in every handler. The reinterpret_cast seems strong but is safe as converting a function with 2 typed pointers and a void return into a function with 2 void pointers and a void return. Associate the structure type with the message number to reduce types and mistakes.