public class SocketFacesListener extends Object implements SystemEventListener
This JSF listener for UIViewRoot
ensures that the necessary JavaScript code to initialize, open or close
the WebSocket
is properly rendered.
Socket
Constructor and Description |
---|
SocketFacesListener(Integer port,
String channel,
String uri,
String functions,
ValueExpression connectedExpression)
Construct an instance of socket event listener based on the given channel, uri, functions and connected expression.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isListenerForSource(Object source)
Only listens on
UIViewRoot . |
void |
processEvent(SystemEvent event)
If event is an instance of
PostAddToViewEvent , then add the main omnifaces.js script
resource. |
public SocketFacesListener(Integer port, String channel, String uri, String functions, ValueExpression connectedExpression)
port
- The port number.channel
- The channel name.uri
- The uri of the web socket representing the channel identifier, which is composed of channel name and
scope identifier, separated by a question mark.
All open websockets on the same uri will receive the same push notification from the server.functions
- The onopen, onmessage and onclose functions.connectedExpression
- The connected expression.public boolean isListenerForSource(Object source)
UIViewRoot
.isListenerForSource
in interface SystemEventListener
public void processEvent(SystemEvent event)
PostAddToViewEvent
, then add the main omnifaces.js
script
resource. Else if event is an instance of PreRenderViewEvent
, and the socket is new, then render the
init()
script, or if it has just switched the connected
attribute, then render either
the open()
script or the close()
script. During an ajax request with partial rendering,
it's added as <eval>
by partial response writer, else it's just added as a script component
with target="body"
. Those scripts will in turn hit SocketEndpoint
.processEvent
in interface SystemEventListener
Copyright © 2012–2016 OmniFaces. All rights reserved.