refactor websocket to angular js service and inject it