Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat to write in MyServerHandler for Netty websocket
    primarykey
    data
    text
    <p>I have wrote my websocket server class and wrote ServerPiplineFactory class but I don't know to write in MyServerHandler class. MyServerHandler class is like </p> <pre><code> public class DiscardServerHandler extends SimpleChannelUpstreamHandler { private static final String WEBSOCKET_PATH = "/websocket"; @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { Object msg = e.getMessage(); //ctx.getChannel().write(msg); //msg.getClass(); if (msg instanceof HttpRequest) { //ctx.getChannel().write(msg); } else if (msg instanceof WebSocketFrame) { System.out.println("I am WebSocketFrame"); } } </code></pre> <p>So I don't know what should I write if I receive HttpRequest and how to send it back to the browser. </p> <p>So if write something like below in my jsp file </p> <pre><code> &lt;/script&gt; var WEBSOCKET_URL = "ws://localhost:8090/websocket"; $(document).ready(function() { ws = new WebSocket(WEBSOCKET_URL); ws.onopen = function(event) { alert("test"); $('#status').text("Waiting...."); }; ws.onmessage = function(event) { var message = jQuery.parseJSON(event.data); alert(message); } var encoded = $.toJSON("test message"); ws.send(encoded); }); &lt;/script&gt; &lt;body&gt; &lt;p id="status"&gt;&amp;nbsp;&lt;/p&gt; &lt;/body&gt; </code></pre> <p>and debug this jsp then it goes to messageReceived then I don't understand what to do then to how websocket server comunicate with server.</p> <p>So if someone can help me to find the document on this or explain a bit about this that would be great.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload