title: Create websocket with play framework 2.6
body: <p>I am trying to do the following with Play Framework 2.6 :</p>
  
  <ol>
  <li>The browser targets the server and a websocket is created</li>
  <li>Later on (after some other request is performed), the servers sends a message to the browser via the websocket previously created</li>
  </ol>
  
  <p>1) Can be easily done with a route :</p>
  
  <pre><code>public WebSocket socket() {
      return WebSocket.Text.accept(request -&gt; {
          // Log events to the console
          Sink&lt;String, ?&gt; in = Sink.foreach(System.out::println);
  
          // Send a single 'Hello!' message and then leave the socket open
          Source&lt;String, ?&gt; out = Source.single("Hello!").concat(Source.maybe());
  
          return Flow.fromSinkAndSource(in, out);
      });
  }
  </code></pre>
  
  <p>and the websocket can be saved server side.</p>
  
  <p>2) But then how can I send data via the websocket ? (triggered server side)</p>
  
  <p>This was easy to do with 2.5 but the documentation is not very helpful for play 2.6.</p>
  
  <p>Thank you</p>