Implemented serialize and deserialize messages