Make chat event loop more generic.