users@websocket-spec.java.net

[jsr356-users] Re: Annotated _at_ClientEndpoints: How does a Client Connect To A Remote Endpoint?

From: Jitendra Kotamraju <jitendra.kotamraju_at_oracle.com>
Date: Mon, 11 Mar 2013 21:27:46 -0700

On 3/11/13 5:01 PM, peter.pilgrim_at_gmail.com wrote:
> Hello All
>
> Annotated @ClientEndpoints: How does a Client Connect To A Remote
> Endpoint?
>
> How does a developer connect the remote WebSocket with just
> annotations?
>
> import javax.websocket.ClientEndpoint;
> import javax.websocket.OnMessage;
> import javax.websocket.Session;
>
> @ClientEndpoint
> public class ClientEchoEndpoint {
>
> @OnMessage
> public void messageReceived( Session session, String text ) {
> System.out.printf("message from the server text: %s\n", text);
> }
> }
>
> Assuming the code runs inside a Java EE7 container.
>
> Also is the client side programmatic API example out there for
> everybody to see?
You need to write code to connect it to server endpoint.
ContainerProvider.getWebSocketContainer.connectToServer(...)