public abstract class AbstractNetChannel<IN,OUT> extends java.lang.Object implements NetChannel<IN,OUT>
NetChannel implementation that handles the basic interaction and Stream and Consumer handling.NetChannel.ConsumerSpec| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
log |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractNetChannel(reactor.core.Environment env,
reactor.io.encoding.Codec<reactor.io.Buffer,IN,OUT> codec,
reactor.event.dispatch.Dispatcher ioDispatcher,
reactor.core.Reactor eventsReactor) |
| Modifier and Type | Method and Description |
|---|---|
reactor.core.composable.Promise<java.lang.Boolean> |
close()
Close this NetChannel.
|
NetChannel<IN,OUT> |
consume(reactor.function.Consumer<IN> consumer)
Efficiently consume incoming decoded data.
|
protected abstract void |
flush()
Subclasses must implement this method to perform IO flushes.
|
reactor.function.Function<reactor.io.Buffer,IN> |
getDecoder() |
reactor.function.Function<OUT,reactor.io.Buffer> |
getEncoder() |
protected reactor.core.Environment |
getEnvironment() |
protected reactor.core.Reactor |
getEventsReactor() |
protected reactor.core.Reactor |
getIoReactor() |
reactor.core.composable.Stream<IN> |
in()
Stream of incoming decoded data. |
void |
notifyError(java.lang.Throwable throwable) |
void |
notifyRead(java.lang.Object obj) |
reactor.function.batch.BatchConsumer<OUT> |
out()
BatchConsumer for efficiently data to the peer. |
boolean |
read(reactor.io.Buffer data)
Performing necessary decoding on the data and notify the internal
Reactor of any results. |
NetChannel<IN,OUT> |
receive(reactor.function.Function<IN,OUT> fn)
Handle incoming data and return the response.
|
reactor.core.composable.Promise<java.lang.Void> |
send(OUT data)
Send data to the peer.
|
protected void |
send(OUT data,
reactor.core.composable.Deferred<java.lang.Void,reactor.core.composable.Promise<java.lang.Void>> onComplete)
Send data on this connection.
|
NetChannel<IN,OUT> |
send(reactor.core.composable.Stream<OUT> data)
Send data to the peer that passes through the given
Stream. |
NetChannel<IN,OUT> |
sendAndForget(OUT data)
Send data to the peer.
|
reactor.core.composable.Promise<IN> |
sendAndReceive(OUT data)
Send data to the peer and expect a response.
|
<T extends java.lang.Throwable> |
when(java.lang.Class<T> errorType,
reactor.function.Consumer<T> errorConsumer)
When an error of the given type occurs, handle it with the given
Consumer. |
protected void |
write(reactor.io.Buffer data,
reactor.core.composable.Deferred<java.lang.Void,reactor.core.composable.Promise<java.lang.Void>> onComplete,
boolean flush)
Subclasses must implement this method to perform the actual IO of writing data to the connection.
|
protected abstract void |
write(java.nio.ByteBuffer data,
reactor.core.composable.Deferred<java.lang.Void,reactor.core.composable.Promise<java.lang.Void>> onComplete,
boolean flush)
Subclasses must implement this method to perform the actual IO of writing data to the connection.
|
protected abstract void |
write(java.lang.Object data,
reactor.core.composable.Deferred<java.lang.Void,reactor.core.composable.Promise<java.lang.Void>> onComplete,
boolean flush)
Subclasses must implement this method to perform the actual IO of writing data to the connection.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, on, remoteAddresspublic reactor.function.Function<reactor.io.Buffer,IN> getDecoder()
public reactor.function.Function<OUT,reactor.io.Buffer> getEncoder()
public reactor.core.composable.Stream<IN> in()
NetChannelStream of incoming decoded data.in in interface NetChannel<IN,OUT>Streampublic reactor.function.batch.BatchConsumer<OUT> out()
NetChannelBatchConsumer for efficiently data to the peer.out in interface NetChannel<IN,OUT>BatchConsumerpublic <T extends java.lang.Throwable> NetChannel<IN,OUT> when(java.lang.Class<T> errorType, reactor.function.Consumer<T> errorConsumer)
NetChannelConsumer.when in interface NetChannel<IN,OUT>T - type of the exceptionerrorType - type of errorerrorConsumer - error handlerpublic NetChannel<IN,OUT> consume(reactor.function.Consumer<IN> consumer)
NetChannelconsume in interface NetChannel<IN,OUT>consumer - the incoming data Consumerpublic NetChannel<IN,OUT> receive(reactor.function.Function<IN,OUT> fn)
NetChannelreceive in interface NetChannel<IN,OUT>fn - request handlerpublic NetChannel<IN,OUT> send(reactor.core.composable.Stream<OUT> data)
NetChannelStream.send in interface NetChannel<IN,OUT>data - the Stream of data to monitorpublic reactor.core.composable.Promise<java.lang.Void> send(OUT data)
NetChannelsend in interface NetChannel<IN,OUT>data - the data to sendPromise indicating when the send operation has completedpublic NetChannel<IN,OUT> sendAndForget(OUT data)
NetChannelsendAndForget in interface NetChannel<IN,OUT>data - the data to sendpublic reactor.core.composable.Promise<IN> sendAndReceive(OUT data)
NetChannelsendAndReceive in interface NetChannel<IN,OUT>data - the data to sendPromise representing the response from the peerpublic reactor.core.composable.Promise<java.lang.Boolean> close()
NetChannelclose in interface NetChannel<IN,OUT>protected void send(OUT data, reactor.core.composable.Deferred<java.lang.Void,reactor.core.composable.Promise<java.lang.Void>> onComplete)
Buffer. The given callback will be invoked when the write has completed.data - The outgoing data.onComplete - The callback to invoke when the write is complete.public boolean read(reactor.io.Buffer data)
Reactor of any results.data - The data to decode.Buffer, false
otherwise.public void notifyRead(java.lang.Object obj)
public void notifyError(java.lang.Throwable throwable)
protected void write(reactor.io.Buffer data,
reactor.core.composable.Deferred<java.lang.Void,reactor.core.composable.Promise<java.lang.Void>> onComplete,
boolean flush)
data - The data to write, as a Buffer.onComplete - The callback to invoke when the write is complete.protected abstract void write(java.nio.ByteBuffer data,
reactor.core.composable.Deferred<java.lang.Void,reactor.core.composable.Promise<java.lang.Void>> onComplete,
boolean flush)
data - The data to write.onComplete - The callback to invoke when the write is complete.flush - whether to flush the underlying IO channelprotected abstract void write(java.lang.Object data,
reactor.core.composable.Deferred<java.lang.Void,reactor.core.composable.Promise<java.lang.Void>> onComplete,
boolean flush)
data - The data to write.onComplete - The callback to invoke when the write is complete.flush - whether to flush the underlying IO channelprotected abstract void flush()
protected reactor.core.Environment getEnvironment()
protected reactor.core.Reactor getEventsReactor()
protected reactor.core.Reactor getIoReactor()