public abstract class NetServerClient extends Object implements AutoCloseable
NetServerChannel
communication channel. A client
application uses a NetServerClient
to send transactions, receive
published messages, or request services from the OBCOM NetServer or
other custom made servers. A NetServerClient
can only be created
using the createClient
method.Modifier and Type | Method and Description |
---|---|
void |
assignLayout(NetServerMessage message)
The
message is assigned the layout identified by its LayoutName label. |
void |
close()
Closes this
NetServerClient , relinquishing any underlying
resources. |
NetServerMessage |
execute(String service,
Object arguments)
Executes a
service with arguments and returns a result
message. |
NetServerMessage |
execute(String service,
Object arguments,
boolean encrypted)
Executes a
service with arguments and returns a result
message. |
NetServerMessage |
execute(String service,
Object arguments,
boolean encrypted,
long timeout)
Executes a
service with arguments and returns a result
message. |
boolean |
getAutoAssignLayout()
Returns
true if the assignLayout method is automatically applied to all reply or published
messages received from the OBCOM NetServer. |
boolean |
getAutoLogin()
Returns
true if login is performed after connecting to OBCOM
NetServer. |
NetServerChannel |
getChannel()
Returns the
NetServerChannel of this NetServerClient . |
String |
getDescription()
Returns the description of this
NetServerClient . |
boolean |
getEncryptAll()
Returns
true if all messages are sent encrypted to OBCOM
NetServer. |
Layout |
getLayout(String name)
Returns the
Layout with the specified name . |
DesktopTask |
getTask()
Returns the
DesktopTask of this NetServerClient . |
String |
getTimestamp()
Returns an OBCOM NetServer timestamp.
|
boolean |
getVerifyLayoutSignatures()
Returns
true if the signatures of downloaded layouts are verified. |
boolean |
isAlive()
Returns
true if this NetServerClient is alive. |
boolean |
isConnected()
Returns
true if connected to the OBCOM NetServer. |
void |
setAutoAssignLayout(boolean value)
Changes whether the
assignLayout
method is automatically applied to all reply or published messages
received from the OBCOM NetServer. |
void |
setVerifyLayoutSignatures(boolean value)
Changes whether the signatures of downloaded layouts are verified.
|
void |
subscribe(String name,
EventHandler<MulticastEvent> handler)
Subscribes to messages published with the specified
name . |
void |
unsubscribe(String name,
EventHandler<MulticastEvent> handler)
Unsubscribes from messages published with the specified
name . |
public final DesktopTask getTask()
DesktopTask
of this NetServerClient
.DesktopTask
or null
if none defined.public final String getDescription()
NetServerClient
.NetServerClient
.public final boolean isConnected()
true
if connected to the OBCOM NetServer.true
if connected to the OBCOM NetServer.public final boolean isAlive()
true
if this NetServerClient
is alive. A NetServerClient
becomes dead when a System Operator executes the
"kill client
" command in an OBCOM NetServer console.true
if this NetServerClient is alive.public final NetServerChannel getChannel()
NetServerChannel
of this NetServerClient
.NetServerChannel
of this NetServerClient
.RuntimeException
- if this client is not alive.public final boolean getEncryptAll()
true
if all messages are sent encrypted to OBCOM
NetServer.true
if all messages are sent encrypted to OBCOM
NetServer.public final boolean getAutoLogin()
true
if login is performed after connecting to OBCOM
NetServer.true
if login is performed after connecting to OBCOM
NetServer.public final boolean getVerifyLayoutSignatures()
true
if the signatures of downloaded layouts are verified.true
if the signatures of downloaded layouts are verified.public final void setVerifyLayoutSignatures(boolean value)
value
- if true
the signatures of downloaded layouts will
be verified, otherwise the signatures will be assigned to layouts
without verification.public final Layout getLayout(String name) throws Exception
Layout
with the specified name
. If the layout
is not available in the cache, it is downloaded, compiled, stored in the
cache and returned to the caller of this method. The signature of the
downloaded layout will be verified if getVerifyLayoutSignatures()
returns true
, otherwise the signature will be assigned to the
layout without verification.name
- name of the required Layout
.Layout
with the specified name
.NullPointerException
- if name
is null
.Exception
- if an error occurs while loading the layout.public final boolean getAutoAssignLayout()
true
if the assignLayout
method is automatically applied to all reply or published
messages received from the OBCOM NetServer.true
if the assignLayout
method is applied to all
reply or published messages.public final void setAutoAssignLayout(boolean value)
assignLayout
method is automatically applied to all reply or published messages
received from the OBCOM NetServer.value
- if true
the assignLayout
method will be
applied to all reply or published messages.public final void assignLayout(NetServerMessage message) throws Exception
message
is assigned the layout identified by its LayoutName
label. If the message
has no such label, then nothing is done. If the message
has a LayoutSignature
label, it is compared with the signature of the assigned layout, and an
exception if thrown if the signatures are not equal.message
- the message that will be assigned a layout.NullPointerException
- if message
is null
.IllegalArgumentException
- if the signatures of the message
and the layout are not equal.Exception
- if another error occurs.public final String getTimestamp() throws Exception
yyyy-MM-dd:HH:mm:ss.cccccc
Exception
- if another error occurs.public final NetServerMessage execute(String service, Object arguments) throws Exception
service
with arguments
and returns a result
message. This is just a convenience method implemented by the following
trivial call statement:
execute(service, arguments, false, 0);
service
- the name of the service.arguments
- the arguments of the service (can be null).NullPointerException
- if an argument is null
.IllegalArgumentException
- if an argument value is invalid.Exception
- if another error occurs.public final NetServerMessage execute(String service, Object arguments, boolean encrypted) throws Exception
service
with arguments
and returns a result
message. If encrypted
is true
the communication with the
OBCOM NetServer will be encrypted. This is just a convenience
method implemented by the following trivial call statement:
execute(service, arguments, encrypted, 0);
service
- the name of the service.arguments
- the arguments of the service (can be null).encrypted
- if true
the communication will be encrypted.NullPointerException
- if an argument is null
.IllegalArgumentException
- if an argument value is invalid.Exception
- if another error occurs.public final NetServerMessage execute(String service, Object arguments, boolean encrypted, long timeout) throws Exception
service
with arguments
and returns a result
message. The service
name has one of the following formats:
{HostName.}ServerName.TranName {HostName.}ServerName.[TranCode]where optional items are shown within "{" and "}" brackets, and the characters ".", "[" and "]" stand for themselves. If the optional
HostName
is not specified, then the OBCOM NetServer Default Host
will be used. TranName
is the name of the requested transaction,
while TranCode
is and alternative one-character identification of
the same transaction. Either TranName
or TranCode
must be
specified. The following are some examples of service names:
ECUSER.[!] ACASER.ACA-TIME HUB.IMSER.AddContactThe
arguments
object will be converted to a String
using
the standard toString
method, hence any object
can be used as argument for a service.
If encrypted
is true
then all communication with the
OBCOM NetServer will be encrypted.
The timeout
argument specifies the amount of milliseconds to wait
for the result message. If timeout
is zero, the call will wait
forever for the result.
service
- the name of the service.arguments
- the arguments of the service (can be null).encrypted
- if true
the communication will be encrypted.timeout
- the maximum time to wait for the reply (milliseconds).NullPointerException
- if an argument is null
.IllegalArgumentException
- if an argument value is invalid.SocketTimeoutException
- if timeout occurs.Exception
- if another error occurs.public final void subscribe(String name, EventHandler<MulticastEvent> handler) throws Exception
name
. When
someone publishes a message with the given name
, the supplied
handler
is called. The name
argument has the following
format:
{HostName.}MulticastNamewhere optional items are shown within "{" and "}" brackets, and the character "." stands for itself. If the optional
HostName
is not
specified, then the OBCOM NetServer Default Host will be used. The
required MulticastName
has a minimum length of 1 and a maximum
length of 10 characters.name
- name of the multicast messages to enable.handler
- the handler called when a multicast message arrives.NullPointerException
- if a required argument is null
.IllegalArgumentException
- if name
is invalid.Exception
- if another error occurs.public final void unsubscribe(String name, EventHandler<MulticastEvent> handler) throws Exception
name
. The
name
argument has the following format:
{HostName.}MulticastNamewhere optional items are shown within "{" and "}" brackets, and the character "." stands for itself. If the optional
HostName
is not
specified, then the OBCOM NetServer Default Host will be used. The
required MulticastName
has a minimum length of 1 and a maximum
length of 10 characters. If MulticastName
equals "*"
,
this method disables the reception of all multicast messages enabled with
the subscribe
method.name
- name of the multicast messages to disable.handler
- the handler called when a multicast message arrives.NullPointerException
- if a required argument is null
.IllegalArgumentException
- if name
is invalid.Exception
- if another error occurs.public final void close()
NetServerClient
, relinquishing any underlying
resources. No other method of this NetServerClient
can be used
after this method has been issued. Calling this method more than once is
allowed but has no effect after the first invocation.close
in interface AutoCloseable
Copyright © OBCOM INGENIERIA S.A. (Chile). All Rights Reserved.