rewrite event and eventmanager, add write event
Basic reactor is finished but buffer is not ok, so the next work is rewriting buffer