Details
-
New Feature
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
Novice
Description
There is a case when I need to maintain my own map (websocket session key, user object). Consequently I need to receive events from onOpen/onClose/onError methods of websocket protocol and add/remove item from my map.
To achieve this :
1) I will add special servlet parameter, let's call it "events" with value "true". Which will enable this feature. By default it will be "false" (no parameter needed) and current functionality will not be influenced any how.
<servlet>
<servlet-name>CamelWsServlet</servlet-name>
<servlet-class>org.apache.camel.component.atmosphere.websocket.CamelWebSocketServlet</servlet-class>
<init-param>
<param-name>events</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
2) I will change WebsocketHandler sending exchange message with header key such as "websocket.eventType" and possible values :
ONOPEN_EVENT_TYPE = 1;
ONCLOSE_EVENT_TYPE = 0;
ONERROR_EVENT_TYPE = -1;
to camel rout each time when we trigger onOpen/onClose/onError methods. In addition to this header parameter session key will be send as well.
3) Rout on client side will filter messages by header to distinguish events and their purposes.