Solution: New class called stream_engine_base which is inherited by ws_engine, zmtp_engine and raw_engine.