users@tyrus.java.net

Re: Only Client APIs with JDK ?

From: Arun Gupta <arun.p.gupta_at_oracle.com>
Date: Tue, 19 Feb 2013 11:24:39 -0800

I connected to the endpoint as:

WebSocketContainer container = ContainerProvider.getWebSocketContainer();
             String uri = "ws://localhost:8080/scalability/websocket";
             System.out.println("Connecting to " + uri);
             container.connectToServer(MyClientEndpoint.class,
URI.create(uri));

Client endpoint is:

@WebSocketClient
public class MyClientEndpoint {
     @WebSocketOpen
     public void onOpen(Session session) {
         System.out.println("Connected to endpoint: " +
session.getRemote());
         try {
             String name = "Duke";
             System.out.println("Sending message to endpoint: " + name);
             session.getRemote().sendString(name);
         } catch (IOException ex) {
Logger.getLogger(MyClientEndpoint.class.getName()).log(Level.SEVERE,
null, ex);
         }
     }

     @WebSocketMessage
     public void processMessage(String message) {
         System.out.println("Received message in client: " + message);
     }
}

None of the System.outs from ClientEndpoint are printed. Where do I
expect them ?

Arun

On 2/19/13 7:35 AM, Pavel Bucek wrote:
> Hi Arun,
>
> you will need:
>
> <dependency>
> <groupId>org.glassfish.tyrus</groupId>
> <artifactId>tyrus-client</artifactId>
> <version>1.0-SNAPSHOT</version>
> </dependency>
> <dependency>
> <groupId>org.glassfish.tyrus</groupId>
> <artifactId>tyrus-container-grizzly</artifactId>
> <version>1.0-SNAPSHOT</version>
> </dependency>
>
> Regards,
> Pavel
>
> On 2/19/13 3:37 PM, Arun Gupta wrote:
>> I'd like to use JSR 356 Client APIs with JDK 7. Is there a
>> stand-alone client.jar that can be used ?
>>
>> Arun
>>
>

-- 
http://twitter.com/arungupta
http://blogs.oracle.com/arungupta