T - Type of listener to expect.public final class ConnectionEventPublisher<T extends ConnectionEventListener> extends ConnectionEventListener implements EventSource<T>, EventPublisher
EventSource and EventListener for connection events.| Constructor and Description |
|---|
ConnectionEventPublisher() |
ConnectionEventPublisher(ConnectionEventPublisher<T> toCopy) |
| Modifier and Type | Method and Description |
|---|---|
ConnectionEventPublisher<T> |
copy() |
void |
onByteRead(long bytesRead)
Event whenever any bytes are read on any open connection.
|
void |
onByteWritten(long bytesWritten)
Event whenever any bytes are successfully written on any open connection.
|
void |
onConnectionCloseFailed(long duration,
java.util.concurrent.TimeUnit timeUnit,
java.lang.Throwable throwable)
Event whenever a connection close failed.
|
void |
onConnectionCloseStart()
Event whenever a close of any connection is issued.
|
void |
onConnectionCloseSuccess(long duration,
java.util.concurrent.TimeUnit timeUnit)
Event whenever a close of any connection is successful.
|
void |
onCustomEvent(java.lang.Object event)
Typically specific instances on
EventListener will provide events that are fired by RxNetty, however,
there may be cases, where a user would want to emit custom events. |
void |
onCustomEvent(java.lang.Object event,
long duration,
java.util.concurrent.TimeUnit timeUnit)
Typically specific instances on
EventListener will provide events that are fired by RxNetty, however,
there may be cases, where a user would want to emit custom events. |
void |
onCustomEvent(java.lang.Object event,
long duration,
java.util.concurrent.TimeUnit timeUnit,
java.lang.Throwable throwable)
Typically specific instances on
EventListener will provide events that are fired by RxNetty, however,
there may be cases, where a user would want to emit custom events. |
void |
onCustomEvent(java.lang.Object event,
java.lang.Throwable throwable)
Typically specific instances on
EventListener will provide events that are fired by RxNetty, however,
there may be cases, where a user would want to emit custom events. |
void |
onFlushComplete(long duration,
java.util.concurrent.TimeUnit timeUnit)
Event whenever flush completes.
|
void |
onFlushStart()
Event whenever a flush is issued on a connection.
|
void |
onWriteFailed(long duration,
java.util.concurrent.TimeUnit timeUnit,
java.lang.Throwable throwable)
Event whenever a write failed on a connection.
|
void |
onWriteStart()
Event whenever a write is issued on a connection.
|
void |
onWriteSuccess(long duration,
java.util.concurrent.TimeUnit timeUnit)
Event whenever data is written successfully on a connection.
|
boolean |
publishingEnabled()
Returns
true if event publishing is enabled. |
rx.Subscription |
subscribe(T listener)
Subscribes the passed
listener for events published by this source. |
onCompletedpublic ConnectionEventPublisher()
public ConnectionEventPublisher(ConnectionEventPublisher<T> toCopy)
public void onByteRead(long bytesRead)
ConnectionEventListeneronByteRead in class ConnectionEventListenerbytesRead - Number of bytes read.public void onByteWritten(long bytesWritten)
ConnectionEventListeneronByteWritten in class ConnectionEventListenerbytesWritten - Number of bytes written.public void onFlushStart()
ConnectionEventListeneronFlushStart in class ConnectionEventListenerpublic void onFlushComplete(long duration,
java.util.concurrent.TimeUnit timeUnit)
ConnectionEventListeneronFlushComplete in class ConnectionEventListenerduration - Duration between flush start and completion.timeUnit - Timeunit for the duration.public void onWriteStart()
ConnectionEventListeneronWriteStart in class ConnectionEventListenerpublic void onWriteSuccess(long duration,
java.util.concurrent.TimeUnit timeUnit)
ConnectionEventListenerConnectionEventListener.onByteWritten(long) to capture number
of bytes written.onWriteSuccess in class ConnectionEventListenerduration - Duration between write start and completion.timeUnit - Timeunit for the duration.public void onWriteFailed(long duration,
java.util.concurrent.TimeUnit timeUnit,
java.lang.Throwable throwable)
ConnectionEventListeneronWriteFailed in class ConnectionEventListenerduration - Duration between write start and failure.timeUnit - Timeunit for the duration.throwable - Error that caused the failure..public void onConnectionCloseStart()
ConnectionEventListeneronConnectionCloseStart in class ConnectionEventListenerpublic void onConnectionCloseSuccess(long duration,
java.util.concurrent.TimeUnit timeUnit)
ConnectionEventListeneronConnectionCloseSuccess in class ConnectionEventListenerduration - Duration between close start and completion.timeUnit - Timeunit for the duration.public void onConnectionCloseFailed(long duration,
java.util.concurrent.TimeUnit timeUnit,
java.lang.Throwable throwable)
ConnectionEventListeneronConnectionCloseFailed in class ConnectionEventListenerduration - Duration between close start and failure.timeUnit - Timeunit for the duration.throwable - Error that caused the failure.public void onCustomEvent(java.lang.Object event)
EventListenerEventListener will provide events that are fired by RxNetty, however,
there may be cases, where a user would want to emit custom events. eg: Creating a custom protocol on top of an
existing protocol like TCP, would perhaps require some additional events. In such a case, this callback can be
utilized.onCustomEvent in interface EventListeneronCustomEvent in class ConnectionEventListenerevent - Event published.EventListener.onCustomEvent(Object, long, TimeUnit),
EventListener.onCustomEvent(Object, Throwable),
EventListener.onCustomEvent(Object, long, TimeUnit, Throwable)public void onCustomEvent(java.lang.Object event,
long duration,
java.util.concurrent.TimeUnit timeUnit)
EventListenerEventListener will provide events that are fired by RxNetty, however,
there may be cases, where a user would want to emit custom events. eg: Creating a custom protocol on top of an
existing protocol like TCP, would perhaps require some additional events. In such a case, this callback can be
utilized.
One should use this overload as opposed to EventListener.onCustomEvent(Object) if the custom event need not be created
per invocation but has to be associated with a duration. This is a simple optimization to reduce event creation
overhead.onCustomEvent in interface EventListeneronCustomEvent in class ConnectionEventListenerevent - Event published.duration - Duration associated with this event. The semantics of this duration is totally upto the published
event.timeUnit - Timeunit for the duration.EventListener.onCustomEvent(Object, long, TimeUnit),
EventListener.onCustomEvent(Object, Throwable),
EventListener.onCustomEvent(Object, long, TimeUnit, Throwable)public void onCustomEvent(java.lang.Object event,
long duration,
java.util.concurrent.TimeUnit timeUnit,
java.lang.Throwable throwable)
EventListenerEventListener will provide events that are fired by RxNetty, however,
there may be cases, where a user would want to emit custom events. eg: Creating a custom protocol on top of an
existing protocol like TCP, would perhaps require some additional events. In such a case, this callback can be
utilized.
One should use this overload as opposed to EventListener.onCustomEvent(Object) if the custom event need not be created
per invocation but has to be associated with a duration and an error. This is a simple optimization to reduce
event creation overhead.onCustomEvent in interface EventListeneronCustomEvent in class ConnectionEventListenerevent - Event published.duration - Duration associated with this event. The semantics of this duration is totally upto the published
event.timeUnit - Timeunit for the duration.throwable - Error associated with the event.EventListener.onCustomEvent(Object, long, TimeUnit),
EventListener.onCustomEvent(Object, Throwable),
EventListener.onCustomEvent(Object, long, TimeUnit, Throwable)public void onCustomEvent(java.lang.Object event,
java.lang.Throwable throwable)
EventListenerEventListener will provide events that are fired by RxNetty, however,
there may be cases, where a user would want to emit custom events. eg: Creating a custom protocol on top of an
existing protocol like TCP, would perhaps require some additional events. In such a case, this callback can be
utilized.
One should use this overload as opposed to EventListener.onCustomEvent(Object) if the custom event need not be created
per invocation but has to be associated with an error. This is a simple optimization to reduce event creation
overhead.onCustomEvent in interface EventListeneronCustomEvent in class ConnectionEventListenerevent - Event published.EventListener.onCustomEvent(Object, long, TimeUnit),
EventListener.onCustomEvent(Object, Throwable),
EventListener.onCustomEvent(Object, long, TimeUnit, Throwable)public rx.Subscription subscribe(T listener)
EventSourcelistener for events published by this source.subscribe in interface EventSource<T extends ConnectionEventListener>listener - Listener for events published by this source.public boolean publishingEnabled()
EventPublishertrue if event publishing is enabled. This is primarily used to short-circuit event publishing
if the publishing is not enabled. Event publishing will be disabled if there are no active listeners or has
been explicitly disabled using RxNetty.disableEventPublishing()publishingEnabled in interface EventPublishertrue if event publishing is enabled.public ConnectionEventPublisher<T> copy()