Add: Refactor ws and rpc to handlers, reuse code