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 class
Msg.Builder
(package private) static class
Msg.Type
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBuffer
buf
static int
COMMAND
static int
CREDENTIAL
private java.nio.channels.SocketChannel
fileDesc
private int
flags
private java.lang.String
group
static int
IDENTITY
static int
MAX_GROUP_LENGTH
private Metadata
metadata
static int
MORE
private int
readIndex
private int
routingId
static int
SHARED
private int
size
private Msg.Type
type
private int
writeIndex
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBuffer
buf()
boolean
check()
byte[]
data()
Returns the message data.java.nio.channels.SocketChannel
fd()
int
flags()
byte
get()
byte
get(int index)
int
getBytes(int index, byte[] dst, int off, int len)
int
getBytes(int index, java.nio.ByteBuffer bb, int len)
java.lang.String
getGroup()
Retrieve the group for RADIO/DISH socketsint
getInt(int offset)
long
getLong(int offset)
Metadata
getMetadata()
int
getRoutingId()
Return the routing id of a message.int
getShort(int offset)
protected int
getWriteIndex()
boolean
hasMore()
void
initDelimiter()
void
initJoin()
void
initLeave()
boolean
isCommand()
boolean
isCredential()
boolean
isDelimiter()
boolean
isIdentity()
boolean
isJoin()
boolean
isLeave()
Msg
put(byte b)
Msg
put(byte[] src)
Msg
put(byte[] src, int off, int len)
Msg
put(int b)
protected Msg
put(int index, byte b)
Msg
put(java.nio.ByteBuffer src)
Msg
put(java.nio.ByteBuffer src, int off, int len)
Msg
putShortString(java.lang.String data)
Puts a string into the message, prefixed with its length.void
resetFlags(int f)
void
resetMetadata()
void
resetRoutingId()
void
setFd(java.nio.channels.SocketChannel fileDesc)
void
setFlags(int flags)
boolean
setGroup(java.lang.String group)
Set the group for RADIO/DISH socketsMsg
setMetadata(Metadata metadata)
boolean
setRoutingId(int routingId)
Set the routing id on a message.protected void
setWriteIndex(int writeIndex)
int
size()
java.lang.String
toString()
void
transfer(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:
toString
in 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()
-
-