Ok, I found that webSocketURL()
can take one argument.
var isSerure = location.protocol === "https:";
var wsUrl = jsRoutes.controllers.MyController.myMethod().webSocketURL(isSecure);
This solved my problem. I don't know where it is documented, but it worked.