EventBus
public interface PushContext
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)
.Modifier and Type | Method and Description |
---|---|
PushContext |
addListener(PushContextListener p)
Deprecated.
Add an event listener.
|
<T> Future<T> |
delay(String channel,
T t,
int time,
TimeUnit unit)
Deprecated.
Delay the push operation until the time expires.
|
<T> Future<T> |
push(String channel,
T t)
Deprecated.
Push message to the one or more channel of communication.
|
PushContext |
removeListener(PushContextListener p)
Deprecated.
Remove a event listener.
|
<T> Future<T> |
schedule(String channel,
T t,
int time,
TimeUnit unit)
Deprecated.
Schedule a period push operation.
|
<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
Copyright © 2017. All rights reserved.