users@websocket-spec.java.net

[jsr356-users] Re: WebSocketPathParam Usage

From: Martin Matula <martin.matula_at_oracle.com>
Date: Fri, 16 Nov 2012 20:28:16 +0100

Say you have an endpoint mapped to the following path:

"chatRooms/{chatRoomName}"

Let's say your client connects to it as follows:

new WebSocket("ws://localhost:8080/chat/chatRooms/MartinsRoom");

That request will get matched to your endpoint with the value of {chatRoomName} set to MartinsRoom. To find out what particular room name the client tries to connect to, you can inject the parameter value on the server side using the @WebSocketPathParam("chatRoomName") annotation on the method parameter you want to inject the value to (exactly like @PathParam in JAX-RS).
Martin

On Nov 16, 2012, at 7:59 PM, Arun Gupta wrote:

> Trying to understand the usage of @WebSocketPathParam.
>
> The WebSocket URI is specified during the connection initialization as:
>
> var websocket = new WebSocket("ws://localhost:8080/helloworld/echo");
>
> When and how a variable part of the URI can be sent from the "client" so that it can be mapped appropriately on the "server" using @WebSocketPathParam ?
>
> Thanks,
> Arun
>
> --
> http://twitter.com/arungupta
> http://blogs.oracle.com/arungupta
>