org.primefaces.push
Interface PushContext

All Known Implementing Classes:
PushContextImpl

public interface PushContext

A PushContext is an object that can be used to send message to application connected to the PushServlet. A communication's channel is always created when an application connects to the PushServlet, and a PushContext can be used to push (or communicate) with the communication's channel. For example, let say an application set a GET request to the Push Servlet in the form of

GET http://127.0.0.1:8080/foo/channel/chat
The PushServlet will create a communication's channel named '/channel/chat'. Sending messages to that channel can be executed by simply doing:
PushContextFactory.getDefault().getPushContext().push('/channel/chat', "some messages");
Using push(String, Object), you can asynchronous push message to one or more channel. You can also schedule periodic push schedule(String, Object, int, java.util.concurrent.TimeUnit). You can also delay push operation by using the delay(String, Object, int, java.util.concurrent.TimeUnit).


Method Summary
 PushContext addListener(PushContextListener p)
          Add an event listener.
<T> Future<T>
delay(String channel, T t, int time, TimeUnit unit)
          Delay the push operation until the time expires.
<T> Future<T>
push(String channel, T t)
          Push message to the one or more channel of communication.
 PushContext removeListener(PushContextListener p)
          Remove a event listener.
<T> Future<T>
schedule(String channel, T t, int time, TimeUnit unit)
          Schedule a period push operation.
 

Method Detail

push

<T> Future<T> push(String channel,
                   T t)
Push message to the one or more channel of communication.

Type Parameters:
T - The type of the message
Parameters:
channel - a channel of communication.
t - a message
Returns:
a Future that can be used to block until the push completes

schedule

<T> Future<T> schedule(String channel,
                       T t,
                       int time,
                       TimeUnit unit)
Schedule a period push operation.

Type Parameters:
T - The type of the message
Parameters:
channel - a channel of communication.
t - a message
time - the time
unit - the @TimeUnit
Returns:
a Future that can used to cancel the periodic push

delay

<T> Future<T> delay(String channel,
                    T t,
                    int time,
                    TimeUnit unit)
Delay the push operation until the time expires.

Type Parameters:
T - The type of the message
Parameters:
channel - a channel of communication.
t - a message
time - the time
unit - the @TimeUnit
Returns:
a Future that can used to cancel the delayed push

addListener

PushContext addListener(PushContextListener p)
Add an event listener.

Parameters:
p - PushContextListener
Returns:
this

removeListener

PushContext removeListener(PushContextListener p)
Remove a event listener.

Parameters:
p - PushContextListener
Returns:
this


Copyright © 2013. All rights reserved.