Package zmq
Class Msg
- java.lang.Object
-
- zmq.Msg
-
- Direct Known Subclasses:
Msg.Builder
public class Msg extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMsg.Builder(package private) static classMsg.Type
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBufferbufstatic intCOMMANDstatic intCREDENTIALprivate java.nio.channels.SocketChannelfileDescprivate intflagsprivate java.lang.Stringgroupstatic intIDENTITYstatic intMAX_GROUP_LENGTHprivate Metadatametadatastatic intMOREprivate intreadIndexprivate introutingIdstatic intSHAREDprivate intsizeprivate Msg.Typetypeprivate intwriteIndex
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBufferbuf()booleancheck()byte[]data()Returns the message data.java.nio.channels.SocketChannelfd()intflags()byteget()byteget(int index)intgetBytes(int index, byte[] dst, int off, int len)intgetBytes(int index, java.nio.ByteBuffer bb, int len)java.lang.StringgetGroup()Retrieve the group for RADIO/DISH socketsintgetInt(int offset)longgetLong(int offset)MetadatagetMetadata()intgetRoutingId()Return the routing id of a message.intgetShort(int offset)protected intgetWriteIndex()booleanhasMore()voidinitDelimiter()voidinitJoin()voidinitLeave()booleanisCommand()booleanisCredential()booleanisDelimiter()booleanisIdentity()booleanisJoin()booleanisLeave()Msgput(byte b)Msgput(byte[] src)Msgput(byte[] src, int off, int len)Msgput(int b)protected Msgput(int index, byte b)Msgput(java.nio.ByteBuffer src)Msgput(java.nio.ByteBuffer src, int off, int len)MsgputShortString(java.lang.String data)Puts a string into the message, prefixed with its length.voidresetFlags(int f)voidresetMetadata()voidresetRoutingId()voidsetFd(java.nio.channels.SocketChannel fileDesc)voidsetFlags(int flags)booleansetGroup(java.lang.String group)Set the group for RADIO/DISH socketsMsgsetMetadata(Metadata metadata)booleansetRoutingId(int routingId)Set the routing id on a message.protected voidsetWriteIndex(int writeIndex)intsize()java.lang.StringtoString()voidtransfer(java.nio.ByteBuffer destination, int srcOffset, int srcLength)
-
-
-
Field Detail
-
MORE
public static final int MORE
- See Also:
- Constant Field Values
-
COMMAND
public static final int COMMAND
- See Also:
- Constant Field Values
-
CREDENTIAL
public static final int CREDENTIAL
- See Also:
- Constant Field Values
-
IDENTITY
public static final int IDENTITY
- See Also:
- Constant Field Values
-
SHARED
public static final int SHARED
- See Also:
- Constant Field Values
-
MAX_GROUP_LENGTH
public static final int MAX_GROUP_LENGTH
- See Also:
- Constant Field Values
-
metadata
private Metadata metadata
-
flags
private int flags
-
type
private Msg.Type type
-
fileDesc
private java.nio.channels.SocketChannel fileDesc
-
size
private final int size
-
buf
private final java.nio.ByteBuffer buf
-
writeIndex
private int writeIndex
-
readIndex
private int readIndex
-
routingId
private int routingId
-
group
private java.lang.String group
-
-
Method Detail
-
isIdentity
public boolean isIdentity()
-
isDelimiter
public boolean isDelimiter()
-
isJoin
public boolean isJoin()
-
isLeave
public boolean isLeave()
-
check
public boolean check()
-
flags
public int flags()
-
hasMore
public boolean hasMore()
-
isCommand
public boolean isCommand()
-
isCredential
public boolean isCredential()
-
setFlags
public void setFlags(int flags)
-
initDelimiter
public void initDelimiter()
-
initJoin
public void initJoin()
-
initLeave
public void initLeave()
-
data
public byte[] data()
Returns the message data. If possible, a reference to the data is returned, without copy. Otherwise a new byte array will be allocated and the data will be copied.- Returns:
- the message data.
-
buf
public java.nio.ByteBuffer buf()
-
size
public int size()
-
resetFlags
public void resetFlags(int f)
-
setFd
public void setFd(java.nio.channels.SocketChannel fileDesc)
-
fd
public java.nio.channels.SocketChannel fd()
-
getMetadata
public Metadata getMetadata()
-
resetMetadata
public void resetMetadata()
-
get
public byte get()
-
get
public byte get(int index)
-
put
public Msg put(byte b)
-
put
public Msg put(int b)
-
put
protected Msg put(int index, byte b)
-
put
public Msg put(byte[] src)
-
put
public Msg put(byte[] src, int off, int len)
-
put
public Msg put(java.nio.ByteBuffer src, int off, int len)
-
put
public Msg put(java.nio.ByteBuffer src)
-
getBytes
public int getBytes(int index, byte[] dst, int off, int len)
-
getBytes
public int getBytes(int index, java.nio.ByteBuffer bb, int len)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getWriteIndex
protected final int getWriteIndex()
-
setWriteIndex
protected final void setWriteIndex(int writeIndex)
-
getLong
public long getLong(int offset)
-
getInt
public int getInt(int offset)
-
getShort
public int getShort(int offset)
-
transfer
public void transfer(java.nio.ByteBuffer destination, int srcOffset, int srcLength)
-
putShortString
public Msg putShortString(java.lang.String data)
Puts a string into the message, prefixed with its length. Users shall size the message by adding 1 to the length of the string: It needs to be able to accommodate (data.length+1) more bytes.- Parameters:
data- a string shorter than 256 characters. If null, defaults to a no-op.- Returns:
- the same message.
-
getRoutingId
public int getRoutingId()
Return the routing id of a message. The routing id represent the CLIENT socket that sent the message to the SERVER socket.- Returns:
- the routing id
-
setRoutingId
public boolean setRoutingId(int routingId)
Set the routing id on a message. The routing id represent the CLIENT socket which the message should be sent to. Only SERVER socket is currently using the routing id.- Parameters:
routingId- the routing id- Returns:
- true if successfully set the routing id.
-
getGroup
public java.lang.String getGroup()
Retrieve the group for RADIO/DISH sockets- Returns:
- the group.
-
setGroup
public boolean setGroup(java.lang.String group)
Set the group for RADIO/DISH sockets- Parameters:
group-- Returns:
- true if successfully set the group.
-
resetRoutingId
public void resetRoutingId()
-
-