Rewrite chatdemo to use a coroutine instead of callbacks.