public final class ERemoteApp extends Object implements EPublisher, ESubscriber, EReplier, ERequestor
ERemoteApp instance is created by
either:
openConnection:
Establishes a connection from this process to a remote
application at the specified Internet address.
EServer: Accepts a connection from a remote
application and encapsulates the accepted
socket.
ERemoteApp instance is responsible for forwarding
advertisements, subscriptions, requests and replies to the
remote application.
An application can track ERemoteApp events for all
connections by subscribing to the message key
net.sf.eBus.client.ConnectionMessage:/eBus.
The ConnectionMessage contains the remote eBus
socket address and whether
the remote eBus is
logged on
or
logged off.
If logged off, an optional reason is provided for why the
eBus logged off. Unsubscribe to stop receiving these updates.
Note: this message key is published locally and cannot be
accessed by remote eBus applications.
Only one connection may exist between any two eBus processes, independent of which process established the first connection. This means that an eBus process may not connect to itself.
| Modifier and Type | Field and Description |
|---|---|
static EMessageKey |
CONNECTION_UPDATE_KEY
eBus connection updates are reported using
ConnectionMessage and the subject
"/eBus". |
static int |
NO_ID
Used to specify that the feed identifier is not set.
|
static String |
NORMAL_LOGOFF
When a remote eBus disconnects by sending a
logoff message,
then the
reason is set to
"logged off". |
| Modifier and Type | Method and Description |
|---|---|
InetSocketAddress |
address()
Returns the host and port of the remote eBus engine to
which this client is connected.
|
void |
cancelRequest(EReplyFeed.ERequest request)
Forward this cancel request to the remote eBus application
if that remote application acknowledged the request.
|
static void |
closeAllConnections()
Closes all currently open connections.
|
static void |
closeConnection(InetSocketAddress address)
Closes a currently open remote eBus client referenced by
the Internet address.
|
static void |
configure(EConfigure config)
Opens the remote eBus connections as per
EConfigure.remoteConnections(). |
static int |
connectionCount()
Returns the number of remote connections.
|
static Collection<InetSocketAddress> |
connections()
Returns a copy of the existing remote eBus application
connections.
|
void |
feedStatus(EFeedState feedState,
ERequestFeed feed)
Ignores request feed state changes.
|
void |
feedStatus(EFeedState feedState,
IESubscribeFeed feed)
Forwards the subscribe feed state to the remote eBus
application if the feed is still in place.
|
boolean |
isConnected()
Returns
true if connected and logged on to the
remote eBus application and false otherwise. |
static boolean |
isConnected(InetSocketAddress a)
Returns
true if there is a connection to the
remote eBus application at the given Internet address
and false otherwise. |
void |
notify(ENotificationMessage msg,
IESubscribeFeed feed)
Forwards the message to the remote eBus application if the
subscription is still in place.
|
static ERemoteApp |
openConnection(EConfigure.RemoteConnection config)
Opens a client socket connection to the remote eBus at
the specified
host and port
and binding the local Internet address to
local port. |
void |
publishStatus(EFeedState feedState,
IEPublishFeed feed)
This callback means that there is or is not a local
subscriber for the remote publisher.
|
void |
reply(int remaining,
EReplyMessage reply,
ERequestFeed.ERequest request)
Forwards the remaining replier count and reply message to
the remote eBus application.
|
void |
request(EReplyFeed.ERequest request)
Assigns a locally unique identifier to this request and
forwards the request to the remote eBus application.
|
String |
toString() |
boolean |
willReconnect()
Returns
true if the connection is automatically
re-established when lost; false otherwise. |
public static final int NO_ID
public static final EMessageKey CONNECTION_UPDATE_KEY
ConnectionMessage and the subject
"/eBus".public static final String NORMAL_LOGOFF
logoff message,
then the
reason is set to
"logged off".public void publishStatus(EFeedState feedState, IEPublishFeed feed)
publishStatus in interface EPublisherfeedState - subscribe to or unsubscribe from the
remote publisher.feed - the publish feed.public void feedStatus(EFeedState feedState, IESubscribeFeed feed)
feedStatus in interface ESubscriberfeedState - the updated subscription state.feed - the state change applies to this subscribe
feed. This is an ESubscribeFeed instance since
multi-key feeds cannot be transmitted to remote
applications.ESubscriber.notify(ENotificationMessage, IESubscribeFeed)public void notify(ENotificationMessage msg, IESubscribeFeed feed)
notify in interface ESubscribermsg - forward this message.feed - subscription feed posting this callback. This
is an ESubscribeFeed instance since multi-key
feeds cannot be transmitted to remote applications.ESubscriber.feedStatus(EFeedState, IESubscribeFeed)public void request(EReplyFeed.ERequest request)
request in interface EReplierrequest - the request instance.EReplier.cancelRequest(EReplyFeed.ERequest)public void cancelRequest(EReplyFeed.ERequest request)
cancelRequest in interface EReplierrequest - cancel this request.EReplier.request(EReplyFeed.ERequest)public void feedStatus(EFeedState feedState, ERequestFeed feed)
feedStatus in interface ERequestorfeedState - the latest request feed state.feed - feed state applies to this feed.ERequestor.reply(int, EReplyMessage, ERequestFeed.ERequest)public void reply(int remaining,
EReplyMessage reply,
ERequestFeed.ERequest request)
This method and remoteRequest(EMessageHeader) are
synchronized to protect against the reply delivery prior
to storing the request information. If not synchronized,
the reply would appear to be for an unknown request.
reply in interface ERequestorremaining - number of repliers still actively
replying.reply - the reply message.request - reply is for this request.ERequestor.feedStatus(EFeedState, ERequestFeed)public InetSocketAddress address()
public boolean willReconnect()
true if the connection is automatically
re-established when lost; false otherwise.true if the connection is automatically
re-established when lost; false otherwise.public boolean isConnected()
true if connected and logged on to the
remote eBus application and false otherwise.true if connected and logged on to the
remote eBus application and false otherwise.public static int connectionCount()
public static Collection<InetSocketAddress> connections()
public static boolean isConnected(InetSocketAddress a)
true if there is a connection to the
remote eBus application at the given Internet address
and false otherwise.a - find a connection to this Internet address.true if there is a connection to the
remote eBus application at the given Internet address
and false otherwise.public static ERemoteApp openConnection(EConfigure.RemoteConnection config)
host and port
and binding the local Internet address to
local port.
If a connection to the given host and type already exists
then throws an IllegalStateException and does
nothing else.
If the bind port is zero, then the local Internet address is bound to any available port.
Only one connection is allowed between eBus engines regardless of which engine initiated the connection. An eBus engine is also precluded from connecting to itself.
config - remote connection configuration.NullPointerException - if config is null.public static void closeConnection(InetSocketAddress address)
address - close the connection to this eBus host
and serverPort.public static void closeAllConnections()
public static void configure(EConfigure config)
EConfigure.remoteConnections().config - contains the remote eBus connection
configuration.Copyright © 2019. All rights reserved.