public class StreamEngine extends java.lang.Object implements IEngine, IPollEvents
Modifier and Type | Class and Description |
---|---|
static class |
StreamEngine.ErrorReason |
private class |
StreamEngine.ProducePongMessage |
private static class |
StreamEngine.Protocol |
Modifier and Type | Field and Description |
---|---|
private Function<Msg,java.lang.Boolean> |
decodeAndPush |
private IDecoder |
decoder |
private IEncoder |
encoder |
private java.lang.String |
endpoint |
private Errno |
errno |
private java.nio.channels.SocketChannel |
fd |
private java.nio.ByteBuffer |
greetingRecv |
private java.nio.ByteBuffer |
greetingSend |
private int |
greetingSize |
private Poller.Handle |
handle |
private static int |
HANDSHAKE_TIMER_ID |
private boolean |
handshaking |
private boolean |
hasHandshakeTimer |
private boolean |
hasHeartbeatTimer |
private boolean |
hasTimeoutTimer |
private boolean |
hasTtlTimer |
private static int |
HEARTBEAT_IVL_TIMER_ID |
private static int |
HEARTBEAT_TIMEOUT_TIMER_ID |
private static int |
HEARTBEAT_TTL_TIMER_ID |
private byte[] |
heartbeatContext |
private int |
heartbeatTimeout |
private java.nio.ByteBuffer |
inpos |
private boolean |
inputStopped |
private int |
insize |
private boolean |
ioError |
private IOObject |
ioObject |
private Mechanism |
mechanism |
private Metadata |
metadata |
private Supplier<Msg> |
nextHandshakeCommand |
private Supplier<Msg> |
nextIdentity |
private Supplier<Msg> |
nextMsg |
private Options |
options |
private ValueReference<java.nio.ByteBuffer> |
outpos |
private boolean |
outputStopped |
private int |
outsize |
private Address |
peerAddress |
private boolean |
plugged |
private Function<Msg,java.lang.Boolean> |
processHandshakeCommand |
private Function<Msg,java.lang.Boolean> |
processIdentity |
private Function<Msg,java.lang.Boolean> |
processMsg |
private Supplier<Msg> |
producePingMessage |
private Supplier<Msg> |
pullAndEncode |
private Supplier<Msg> |
pullMsgFromSession |
private Function<Msg,java.lang.Boolean> |
pushMsgToSession |
private Function<Msg,java.lang.Boolean> |
pushOneThenDecodeAndPush |
private Function<Msg,java.lang.Boolean> |
pushRawMsgToSession |
private SessionBase |
session |
private static int |
SIGNATURE_SIZE |
private SocketBase |
socket |
private boolean |
subscriptionRequired |
private static int |
V2_GREETING_SIZE |
private static int |
V3_GREETING_SIZE |
private Function<Msg,java.lang.Boolean> |
writeCredential |
private StreamEngine.Protocol |
zmtpVersion |
Constructor and Description |
---|
StreamEngine(java.nio.channels.SocketChannel fd,
Options options,
java.lang.String endpoint) |
Modifier and Type | Method and Description |
---|---|
private boolean |
decodeAndPush(Msg msg) |
private boolean |
decodeCurrentInputs() |
private void |
decodeDataAfterHandshake(int greetingSize) |
void |
destroy() |
private void |
error(StreamEngine.ErrorReason error) |
java.lang.String |
getEndPoint() |
private boolean |
handshake() |
private int |
heartbeatTimeout() |
private Msg |
identityMsg() |
void |
inEvent()
Called by I/O thread when file descriptor is ready for reading.
|
private <T> T |
instantiate(java.lang.Class<T> clazz,
int size,
long max) |
private void |
mechanismReady() |
private Msg |
nextHandshakeCommand() |
void |
outEvent()
Called by I/O thread when file descriptor is ready for writing.
|
void |
plug(IOThread ioThread,
SessionBase session) |
private boolean |
processCommand(Msg msg) |
private boolean |
processHandshakeCommand(Msg msg) |
private boolean |
processHeartbeatMessage(Msg msg) |
private boolean |
processIdentityMsg(Msg msg) |
private Msg |
producePingMessage() |
private Msg |
producePongMessage(byte[] pingContext) |
private Msg |
pullAndEncode() |
private Msg |
pullMsgFromSession() |
private boolean |
pushMsgToSession(Msg msg) |
private boolean |
pushOneThenDecodeAndPush(Msg msg) |
private boolean |
pushRawMsgToSession(Msg msg) |
private int |
read(java.nio.ByteBuffer buf) |
void |
restartInput() |
void |
restartOutput() |
private void |
setHandshakeTimer() |
void |
terminate() |
void |
timerEvent(int id)
Called when timer expires.
|
java.lang.String |
toString() |
private void |
unplug() |
private int |
write(java.nio.ByteBuffer outbuf) |
private boolean |
writeCredential(Msg msg) |
void |
zapMsgAvailable() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
acceptEvent, connectEvent
private IOObject ioObject
private java.nio.channels.SocketChannel fd
private Poller.Handle handle
private java.nio.ByteBuffer inpos
private int insize
private IDecoder decoder
private final ValueReference<java.nio.ByteBuffer> outpos
private int outsize
private IEncoder encoder
private Metadata metadata
private boolean handshaking
private static final int SIGNATURE_SIZE
private static final int V2_GREETING_SIZE
private static final int V3_GREETING_SIZE
private int greetingSize
private final java.nio.ByteBuffer greetingRecv
private final java.nio.ByteBuffer greetingSend
private StreamEngine.Protocol zmtpVersion
private SessionBase session
private final Options options
private final java.lang.String endpoint
private boolean plugged
private boolean ioError
private boolean subscriptionRequired
private Mechanism mechanism
private boolean inputStopped
private boolean outputStopped
private static final int HANDSHAKE_TIMER_ID
private static final int HEARTBEAT_TTL_TIMER_ID
private static final int HEARTBEAT_IVL_TIMER_ID
private static final int HEARTBEAT_TIMEOUT_TIMER_ID
private boolean hasHandshakeTimer
private boolean hasTtlTimer
private boolean hasTimeoutTimer
private boolean hasHeartbeatTimer
private final int heartbeatTimeout
private final byte[] heartbeatContext
private SocketBase socket
private final Address peerAddress
private final Errno errno
public StreamEngine(java.nio.channels.SocketChannel fd, Options options, java.lang.String endpoint)
private int heartbeatTimeout()
public void destroy()
public void plug(IOThread ioThread, SessionBase session)
private <T> T instantiate(java.lang.Class<T> clazz, int size, long max)
private void unplug()
public void inEvent()
IPollEvents
inEvent
in interface IPollEvents
public void outEvent()
IPollEvents
outEvent
in interface IPollEvents
public void restartOutput()
restartOutput
in interface IEngine
public void restartInput()
restartInput
in interface IEngine
private boolean decodeCurrentInputs()
private boolean handshake()
private void decodeDataAfterHandshake(int greetingSize)
private Msg identityMsg()
private boolean processIdentityMsg(Msg msg)
private Msg nextHandshakeCommand()
private boolean processHandshakeCommand(Msg msg)
public void zapMsgAvailable()
zapMsgAvailable
in interface IEngine
private void mechanismReady()
private Msg pullMsgFromSession()
private boolean pushMsgToSession(Msg msg)
private boolean pushRawMsgToSession(Msg msg)
private boolean writeCredential(Msg msg)
private Msg pullAndEncode()
private boolean decodeAndPush(Msg msg)
private boolean pushOneThenDecodeAndPush(Msg msg)
private void error(StreamEngine.ErrorReason error)
private void setHandshakeTimer()
public void timerEvent(int id)
IPollEvents
timerEvent
in interface IPollEvents
id
- the ID of the expired timer.private Msg producePingMessage()
private Msg producePongMessage(byte[] pingContext)
private boolean processCommand(Msg msg)
private boolean processHeartbeatMessage(Msg msg)
private int write(java.nio.ByteBuffer outbuf)
private int read(java.nio.ByteBuffer buf)
public java.lang.String getEndPoint()
getEndPoint
in interface IEngine
public java.lang.String toString()
toString
in class java.lang.Object