I need to write an update to that article. -- Joakim Erdfelt <[email protected]> webtide.com <http://www.webtide.com/> - intalio.com/jetty Expert advice, services and support from from the Jetty & CometD experts eclipse.org/jetty - cometd.org
On Wed, Jan 15, 2014 at 2:05 PM, Ken OKABE <[email protected]> wrote: > Hi Joakim Erdfelt, > > Thanks to your advice, I understand. > > Probably, I can get through this issue since every factor seems > well-defined to me by your answer. > > During this research, I've read your article: > > http://webtide.intalio.com/2012/10/jetty-9-updated-websocket-api/ > > > Regards, > > Ken > > > > On Thu, Jan 16, 2014 at 5:15 AM, Joakim Erdfelt <[email protected]> > wrote: > > see a simple example at > > > > > http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-websocket/websocket-client/src/test/java/examples?id=jetty-9.1.1.v20140108 > > > > There's no need to be mucking about with WebSocketSessionFactory, > > EventDriver, or LogicalConnection. > > Just keep it simple, use the socket you pass in as your communications > > channel. > > The Socket is configured by you to receive messages, and you use the > session > > (obtained during socket open) to get information about the connection. > > Use the session.getRemote() to send messages. > > > > > > -- > > Joakim Erdfelt <[email protected]> > > webtide.com - intalio.com/jetty > > Expert advice, services and support from from the Jetty & CometD experts > > eclipse.org/jetty - cometd.org > > > > > > On Wed, Jan 15, 2014 at 12:54 PM, Ken OKABE <[email protected]> wrote: > >> > >> Hi, I'm new to Jerry, and trying to implement WebSocket Client on > Jetty9. > >> > >> I saw an example on Jetty8. > >> > >> org.eclipse.jetty.websocket Class WebSocketClient > >> > >> > >> > http://archive.eclipse.org/jetty/8.0.0.v20110901/apidocs/org/eclipse/jetty/websocket/WebSocketClient.html > >> > >> to create a new instance of WebSocketClient is : > >> //===================================================== > >> WebSocketClientFactory factory = new WebSocketClientFactory(); > >> factory.start(); > >> > >> WebSocketClient client = factory.newWebSocketClient(); > >> // Configure the client > >> > >> WebSocket.Connection connection = client.open(new > >> URI("ws://127.0.0.1:8080/"), new WebSocket.OnTextMessage() > >> { > >> public void onOpen(Connection connection) > >> { > >> // open notification > >> } > >> > >> public void onClose(int closeCode, String message) > >> { > >> // close notification > >> } > >> > >> public void onMessage(String data) > >> { > >> // handle incoming message > >> } > >> }).get(5, TimeUnit.SECONDS); > >> > >> connection.sendMessage("Hello World"); > >> //=========================================================== > >> > >> However, I've never seen a document for Jetty9 for this. > >> > >> So far, referring to > >> > >> > http://download.eclipse.org/jetty/9.1.0.v20131115/apidocs/org/eclipse/jetty/websocket/common/SessionFactory.html#createSession%28java.net.URI,%20org.eclipse.jetty.websocket.common.events.EventDriver,%20org.eclipse.jetty.websocket.common.LogicalConnection%29 > >> > >> //---------------------------------------------- > >> WebSocketSession createSession(URI requestURI, > >> EventDriver websocket, > >> LogicalConnection connection) > >> //---------------------------------------------- > >> > >> I've tried > >> > >> //=========================================================== > >> try > >> { > >> WebSocketSession session = factory.createSession(uri, > >> eventDriver, connection); > >> RemoteEndpoint ep = session.getRemote(); > >> } > >> catch (Exception ex) > >> { > >> System.out.println("=ERROR= " + ex); > >> //=ERROR= java.lang.NullPointerException > >> } > >> > >> private EventDriver eventDriver = new EventDriver() > >> { > >> @Override > >> public WebSocketPolicy getPolicy() > >> { > >> return null; > >> } > >> > >> //...................................... > >> > >> @Override > >> public void incomingFrame(Frame frame) > >> { > >> > >> } > >> }; > >> > >> private LogicalConnection connection = new LogicalConnection() > >> { > >> @Override > >> public void close() > >> { > >> > >> } > >> > >> //............................... > >> > >> > >> @Override > >> public void resume() > >> { > >> > >> } > >> }; > >> //=========================================================== > >> > >> but I've encounter java.lang.NullPointerException > >> > >> How do we implement Jetty9 WebSocket Client ?? > >> > >> Thanks for your advise. > >> > >> Ken > >> _______________________________________________ > >> jetty-users mailing list > >> [email protected] > >> https://dev.eclipse.org/mailman/listinfo/jetty-users > > > > > > > > _______________________________________________ > > jetty-users mailing list > > [email protected] > > https://dev.eclipse.org/mailman/listinfo/jetty-users > > > _______________________________________________ > jetty-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/jetty-users >
_______________________________________________ jetty-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/jetty-users
