title: Dynamically get web socket URL
body: <p>I have a Play 2.5 application that uses a web socket. In my Controller I establish it as</p>
  
  <pre><code>  def socket = WebSocket.accept[JsValue, JsValue] { request =&gt;
      ActorFlow.actorRef(out =&gt; TroiWebSocket.props(db, out, comm.communicator, system))
    }
  </code></pre>
  
  <p>And, it's accessed in my routes as</p>
  
  <pre><code>GET     /push-notifications         controllers.Application.socket
  </code></pre>
  
  <p>As, currently, my application is running locally, I can reference the socket  in a javascript file using</p>
  
  <pre><code>var socket = new WebSocket("ws://localhost:9000/push-notifications");
  </code></pre>
  
  <p>However, I'm starting to move my stuff away from the localhost, and need a way to reference the url in my javascript file. This URL might change (and could be different depending on the development environment). So, how can I reference this URL dynamically? That is, how do I say </p>
  
  <pre><code>var socket = new Websocket(URL_OF_WEBSOCKET)
  </code></pre>
  
  <p>I thought of breaking it up in my config files and trying to do it that way, but I'm not so sure that would work.</p>
  
  <p>Any and all help would be appreciated.</p>