webchat: refactor to rpc