added receive_event macro, reworked demos to use it