Implemented ProtocolEncoder.