public class Mdf
extends java.lang.Object
| Constructor and Description |
|---|
Mdf()
Constructs a new
MessageHeader object. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
connect(java.lang.String servers)
Connects to a server specified in the servers string.
|
int |
consume(int timeout)
Consumes any bytes from the server (if any).
|
void |
disconnect()
Disconnects from the server.
|
protected void |
finalize() |
MessageField |
get_next_field()
Returns the current field in the message and proceed the internal
position to the next field in the message.
|
MessageHeader |
get_next_message()
Returns the header of the current message in the stream.
|
java.lang.String |
getBindAddress()
Gets the (by the user) set IPv4 or IPv6 address to bind to before connecting
|
java.lang.String |
getCipher()
Returns the encryption cipher chosen by the server for the connection, only availably after
connect returns |
java.lang.String |
getCiphers()
Returns the encryption ciphers that the client will offer to the server upon connect
|
java.lang.String |
getConnectedHostIP()
Returns the ip of the server we are connected to, only availably after
connect returns |
java.lang.String |
getConnectedHostName()
Returns the host name of the server we are connected to, only availably after
connect returns |
java.lang.String |
getDigest()
Returns the message digest chosen by the server for the connection, only availably after
connect returns |
java.lang.String |
getDigests()
Returns the message digests that the client will offer to the server upon connect
|
int |
getError()
Gets the internal libmdf error code
|
int |
getHandleDelay()
Returns if we have enabled delay-mode or not.
|
int |
getHeartbeatInterval()
Gets the Heartbeat Interval property.
|
int |
getHeartbeatMaxMissed()
Gets Max Missed Heartbeats property.
|
java.util.ArrayList<MessageHeader> |
getMessagesAndFields()
Calls
get_next_message() + get_next_field()
repeatedly and constructs an ArrayList in order to minimize
the amount of Java to native calls for performance critical and latency
sensitive client applications. |
int |
getNoEncryption()
Gets the status of the Client to Server encryption.
|
long |
getReceivedBytes()
Gets the "Number of bytes received from the server" property.
|
long |
getSentBytes()
Gets the "Number of bytes sent to the server" property
|
int |
getTCPNoDelay()
Gets the status of the TCP Nagle algorithm.
|
int |
getTimeDifference()
Gets the Time Difference property.
|
long |
getTimeDifferenceNS()
Gets the Time DifferenceNS property.
|
int |
getTimeout()
Gets the Connection Timeout property.
|
boolean |
send(Message message)
Send the message chain to the server.
|
boolean |
setBindAddress(java.lang.String address)
Sets the IPv4 or IPv6 address to bind to before connecting
|
java.lang.String |
setCiphers(java.lang.String ciphers)
Sets the encryption ciphers that the client will offer to the server upon connect
|
boolean |
setConsumeDataCallback(Callback callback)
Registers a consumeData Callback
|
java.lang.String |
setDigests(java.lang.String digests)
Sets the message digests that the client will offer to the server upon connect
|
boolean |
setHandleDelay(int value)
Enables/Disables delay-mode.
|
boolean |
setHeartbeatInterval(int value)
Sets the Heartbeat Interval property.
|
boolean |
setHeartbeatMaxMissed(int value)
Sets the Max Missed Heartbeats property.
|
boolean |
setNoEncryption(int value)
Disable the Client to Server encryption.
|
boolean |
setReceivedBytes(long value)
Sets the "Number of bytes received from the server" property.
|
boolean |
setSentBytes(long value)
Sets the "Number of bytes sent to the server" property
|
boolean |
setStatusChangeCallback(Callback callback)
Registers a statusChange Callback
|
boolean |
setTCPNoDelay(int value)
Disable the TCP Nagle algorithm.
|
boolean |
setTimeout(int value)
Sets the Connection Timeout property,
|
public Mdf()
MessageHeader object. The object is not thread-safe
but different threads can access different objects simultaneously.protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic MessageHeader get_next_message()
getMessagesAndFields() method instead.MessageHeaderpublic MessageField get_next_field()
getMessagesAndFields() method instead.MessageFieldpublic java.util.ArrayList<MessageHeader> getMessagesAndFields()
get_next_message() + get_next_field()
repeatedly and constructs an ArrayList in order to minimize
the amount of Java to native calls for performance critical and latency
sensitive client applications. When this method is used the getFields()
method in the MessageHeader class can be called in order to get
the ArrayList of the fields.consume() method.MessageHeaderpublic boolean connect(java.lang.String servers)
"server:port" where server
can be a host name or a raw IP address (IPv6 must be enclosed in brackets
"[address]", if the first server does not respond in time, the next will
be tried and so on until there is no more servers in the list.servers - a comma separated list in the form of "server:port"public void disconnect()
public int consume(int timeout)
timeout is the time in seconds to wait for data from the
server, if zero the function will return immediately if there is no data
to consume.timeout - time in seconds to wait for data from the serverCallbackpublic boolean send(Message message)
message - the message to be sent to the serverMessagepublic boolean setTimeout(int value)
value - the number of seconds before determining that a connection attempt has timed out. Valid values are 1-60.public int getTimeout()
public boolean setHeartbeatInterval(int value)
value - the number of seconds the connection must be idle before the API sends a hearbeat request to the server. Valid values are 1-86400.public int getHeartbeatInterval()
public boolean setHeartbeatMaxMissed(int value)
value - how many outstanding heartbeat requests to allow before the connection is determined to be disconnected. Valid values are 1-100.public int getHeartbeatMaxMissed()
public boolean setTCPNoDelay(int value)
value - '1' will disable the Nagle algorithm, '0' will enable it (the default).public int getTCPNoDelay()
public boolean setNoEncryption(int value)
value - '1' will disable client to server traffic encryption, '0' will enable it (the default). Once disabled it cannot be enabled again until the connection is closed.public int getNoEncryption()
public int getTimeDifference()
public long getTimeDifferenceNS()
public boolean setReceivedBytes(long value)
value - number of bytes, can NOT be negativepublic long getReceivedBytes()
public boolean setSentBytes(long value)
value - number of bytes, can NOT be negativepublic long getSentBytes()
public int getError()
public boolean setBindAddress(java.lang.String address)
address - a numerical IPv4 or IPv6 address to bind to, can be null if the intention is to unset the bind addresspublic java.lang.String getBindAddress()
public java.lang.String setCiphers(java.lang.String ciphers)
ciphers - a comma separated list of the encryption ciphers offered by the client to the server, can be null if the intention is to use the default listpublic java.lang.String getCiphers()
public java.lang.String getCipher()
connect returnspublic java.lang.String setDigests(java.lang.String digests)
digests - a comma separated list of the message digest offered by the client to the server, can be null if the intention is to use the default listpublic java.lang.String getDigests()
public java.lang.String getDigest()
connect returnspublic boolean setHandleDelay(int value)
value - '1' will enable delay-mode, '0' will disable it (the default).public int getHandleDelay()
public java.lang.String getConnectedHostName()
connect returnspublic java.lang.String getConnectedHostIP()
connect returnspublic boolean setConsumeDataCallback(Callback callback)
callback - an implementation of Callback interface, can be null if the intention is to unset the callbackpublic boolean setStatusChangeCallback(Callback callback)
callback - an implementation of Callback interface, can be set to null if the intention is to unset the callback