I hate to ask such a vague question, but I'm having a hard time finding a simple example. That's what I have so far:
Public Sector JettyWebSocketServlet extends WebSocketServlet {@Override Configure Public Zero (factory). (Factory.register (MyEchoSocket.class); }} @WebSocket Public Square MyEchoSocket {@OnWebSocketMessage Text on Public Zero (WebSocket Connection Connection, String Message) {System.out.println ("Text:" + Message); {Conn.write (Tap, New FutureCollection (), "Found:" + Try); } Hold (exception e) {e.printStackTrace (); }}} In embedded Jetty examples, I can always show something like the following to start running a server instance, but I do not know how to update my WebSocketServlet. server server = new server (8080); Server.start (); Server.join (); How can I create an embedded server that can handle the webserver connection request?
Update: December 2, 2013 Embedded See for example a date with WebSock with JetT:
Original Answer An example of test cases Has been found.
Short answer:
server server = new server (8080); WebSocketHandler wsHandler = New WebSketchesHandler () {@Override Configure Public Zero (); factory.register (MyEchoSocket.class); }}; Server.addHandler (wsHandler); Server.start (); Server.join (); This will create a simple server that controls 1 reference, the original reference.
http: // localhost: 8080 / If you want to pair WebSocketHandler in another context, wrap it in a contextual handler.
server server = new server (8080); WebSocketHandler wsHandler = New WebSketchesHandler () {@Override Configure Public Zero (); factory.register (MyEchoSocket.class); }}; Reference Handler Reference = New ReferencesHandler (); Context.setContextPath ("/ echo"); Context.setHandler (wsHandler); Server.addHandler (reference); Server.start (); Server.join (); This is your websocket
http: // localhost: 8080 / echo /
No comments:
Post a Comment