add a template class for handling messages