public class OtpMsg
extends java.lang.Object
Provides a carrier for Erlang messages.
Instances of this class are created to package header and payload information
in received Erlang messages so that the recipient can obtain both parts with
a single call to receiveMsg()
.
The header information that is available is as follows:
pid
or as a String, but never both.
regSendTag
contain sender information.
Message are sent using the Erlang external format (see separate
documentation). When a message is received and delivered to the recipient
mailbox
, the body of the message is still in this external
representation until getMsg()
is called, at which point the
message is decoded. A copy of the decoded message is stored in the OtpMsg so
that subsequent calls to getMsg()
do not require that the
message be decoded a second time.
Modifier and Type | Field and Description |
---|---|
static int |
exit2Tag |
static int |
exitTag |
static int |
linkTag |
static int |
regSendTag |
static int |
sendTag |
static int |
unlinkTag |
Modifier and Type | Method and Description |
---|---|
OtpErlangObject |
getMsg()
Deserialize and return a new copy of the message contained in this
OtpMsg.
|
java.lang.Object |
getRecipient()
Get the name of the recipient for this message, if it is a regSendTag
message.
|
java.lang.String |
getRecipientName()
Get the name of the recipient for this message.
|
OtpErlangPid |
getRecipientPid()
Get the Pid of the recipient for this message, if it is a sendTag
message.
|
OtpErlangPid |
getSenderPid()
Get the Pid of the sender of this message.
|
int |
type()
Get the type marker from this message.
|
public static final int exit2Tag
public static final int exitTag
public static final int linkTag
public static final int regSendTag
public static final int sendTag
public static final int unlinkTag
public OtpErlangObject getMsg() throws OtpErlangDecodeException
Deserialize and return a new copy of the message contained in this OtpMsg.
The first time this method is called the actual payload is deserialized and the Erlang term is created. Calling this method subsequent times will not cuase the message to be deserialized additional times, instead the same Erlang term object will be returned.
OtpErlangDecodeException
- if the byte stream could not be deserialized.public java.lang.Object getRecipient()
Get the name of the recipient for this message, if it is a regSendTag message.
Messages are sent to Pids or names. If this message was sent to a name then the name is returned by this method.
public java.lang.String getRecipientName()
Get the name of the recipient for this message.
Messages are sent to Pids or names. If this message was sent to a name then the name is returned by this method.
public OtpErlangPid getRecipientPid()
Get the Pid of the recipient for this message, if it is a sendTag message.
Messages are sent to Pids or names. If this message was sent to a Pid then the Pid is returned by this method. The recipient Pid is also available for link, unlink and exit messages.
public OtpErlangPid getSenderPid()
Get the Pid of the sender of this message.
For messages sent to names, the Pid of the sender is included with the message. The sender Pid is also available for link, unlink and exit messages. It is not available for sendTag messages sent to Pids.
public int type()
Get the type marker from this message. The type marker identifies the type of message. Valid values are the ``tag'' constants defined in this class.
The tab identifies not only the type of message but also the content of the OtpMsg object, since different messages have different components, as follows:
Pid
and it is available through
getRecipientPid()
. Sender information is not
available. The message body can be retrieved with getMsg()
.getRecipientName()
. Sender information is available through
#getSenderPid getSenderPid()}. The message body can be retrieved with
getMsg()
.getMsg()
.