Refactored message encoding and decoding to make the encoding method interchangeable, json, msgpack, etc.
Applied visitor pattern for messages.