public interface CometHandler<E>
CometContext.addCometHandler(CometHandler)
automatically tells Grizzly Comet to suspend the underlying connection and to avoid
committing the response. Since the response is not committed, the connection is considered as suspended and can be
resumed later when an event happens by invoking CometContext.resumeCometHandler(CometHandler)
, from onEvent(org.glassfish.grizzly.comet.CometEvent)
. CometContext.resumeCometHandler(CometHandler)
, resume the connection by committing the
response. As an example, a browser icons will spins when a connection is suspended, as the complete response hasn't
been sent back.
Components that implement this interface will be notified Object.notify()
is invoked
or when the CometContext.getExpirationDelay()
expires.Modifier and Type | Method and Description |
---|---|
CometContext<E> |
getCometContext() |
Response |
getResponse() |
void |
onEvent(CometEvent event)
Receive
CometEvent notification. |
void |
onInitialize(CometEvent event)
Receive
CometEvent notification when Grizzly is about to suspend the connection. |
void |
onInterrupt(CometEvent event)
Receive
CometEvent notification when the underlying tcp communication is resumed by Grizzly. |
void |
onTerminate(CometEvent event)
Receive
CometEvent notification when the response is resumed by a CometHandler or by the CometContext |
void |
setCometContext(CometContext<E> context) |
void |
setResponse(Response response) |
Response getResponse()
void setResponse(Response response)
CometContext<E> getCometContext()
void setCometContext(CometContext<E> context)
void onEvent(CometEvent event) throws IOException
CometEvent
notification. This method will be invoked every time a CometContext.notify(E)
is
invoked. The CometEvent
will contains the message that can be pushed back to the remote client, cached or
ignored. This method can also be used to resume a connection once a notified by invoking CometContext.resumeCometHandler(org.glassfish.grizzly.comet.CometHandler)
.IOException
void onInitialize(CometEvent event) throws IOException
CometEvent
notification when Grizzly is about to suspend the connection. This method is always
invoked during the processing of CometContext.addCometHandler(org.glassfish.grizzly.comet.CometHandler<E>)
operations.IOException
void onTerminate(CometEvent event) throws IOException
CometEvent
notification when the response is resumed by a CometHandler
or by the CometContext
IOException
void onInterrupt(CometEvent event) throws IOException
CometEvent
notification when the underlying tcp communication is resumed by Grizzly. This happens
when the CometContext.setExpirationDelay(long)
expires or when the remote client close the connection.IOException
Copyright © 2014 Oracle Corporation. All rights reserved.