|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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/chatThe 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. |
|
|
delay(String channel,
T t,
int time,
TimeUnit unit)
Delay the push operation until the time expires. |
|
|
push(String channel,
T t)
Push message to the one or more channel of communication. |
|
PushContext |
removeListener(PushContextListener p)
Remove a event listener. |
|
|
schedule(String channel,
T t,
int time,
TimeUnit unit)
Schedule a period push operation. |
Method Detail |
---|
<T> Future<T> push(String channel, T t)
T
- The type of the messagechannel
- a channel of communication.t
- a message
<T> Future<T> schedule(String channel, T t, int time, TimeUnit unit)
T
- The type of the messagechannel
- a channel of communication.t
- a messagetime
- the timeunit
- the @TimeUnit
<T> Future<T> delay(String channel, T t, int time, TimeUnit unit)
T
- The type of the messagechannel
- a channel of communication.t
- a messagetime
- the timeunit
- the @TimeUnit
PushContext addListener(PushContextListener p)
p
- PushContextListener
PushContext removeListener(PushContextListener p)
p
- PushContextListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |