class cMsgServerBridge
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
cMsgServerBridge.SendAndGetCallback
This class defines the callback to be run when a sendAndGet response message
arrives from a bridge connection and must be passed on to a client(s).
|
(package private) static class |
cMsgServerBridge.SubscribeCallback
This class defines the callback to be run when a message matching
our subscription arrives from a bridge connection and must be
passed on to a client(s).
|
Modifier and Type | Field and Description |
---|---|
(package private) cMsgServerClient |
client
Client of cMsg server this object is a bridge to.
|
(package private) java.lang.String |
serverName
Name of cMsg server ("host:port") this server is connected to.
|
Constructor and Description |
---|
cMsgServerBridge(cMsgNameServer nameServer,
java.lang.String serverName,
int thisNsTcpPort,
int thisNsUdpPort)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
cloudLock(int delay)
This method grabs the cloud lock of a connected server in order to add
this server to the cMsg domain server cloud.
|
(package private) void |
cloudUnlock()
This method releases the cloud lock of a connected server when adding
this server to the cMsg domain server cloud.
|
java.util.Set<java.lang.String> |
connect(boolean isOriginator,
java.lang.String cloudPassword,
java.lang.String clientPassword,
boolean multicasting)
Method to connect to server.
|
(package private) java.lang.String[] |
getClientNamesAndNamespaces()
This method gets the names of all the local clients (not servers)
of another cMsg domain server.
|
(package private) int |
getCloudStatus()
This method gets the cloud status of the server this server is
connected to.
|
static cMsgCallbackAdapter |
getSendAndGetCallback(int id,
int sysMsgId)
Get a callback for a sendAndGet call.
|
static cMsgCallbackAdapter |
getSubAndGetCallback()
This method returns a reference to the one callback needed for
subscribes and subAndGets to propogate messages back to
original client.
|
void |
printSizes()
This method prints sizes of maps for debugging purposes.
|
(package private) boolean |
registrationLock(int delay)
This method grabs the registration lock (for adding a client)
of another cMsg domain server.
|
(package private) void |
registrationUnlock()
This method releases the registration lock (when adding a client)
of another cMsg domain server.
|
void |
sendAndGet(cMsgMessage msg,
java.lang.String namespace,
cMsgCallbackInterface cb)
Method to do a sendAndGet of a message of subject and type to another cMsg server.
|
(package private) void |
setCloudStatus(int cloudStatus)
This method locally sets the cloud status of the server this server is
connected to through this bridge.
|
void |
setServerName(java.lang.String serverName)
Sets the name of the server this bridge's client is connected to.
|
void |
shutdownClients(java.lang.String clientName,
boolean includeMe)
Method to shutdown the given clients.
|
void |
shutdownServer()
Method to shutdown the given server this client is connected to.
|
void |
subscribe(java.lang.String subject,
java.lang.String type,
java.lang.String namespace)
Method for a server to subscribe to receive messages of a subject
and type from another cMsg server.
|
void |
subscribeAndGet(java.lang.String subject,
java.lang.String type,
java.lang.String namespace,
cMsgCallbackInterface cb)
Method for a subscribeAndGet (a one-time subscribe) on another cMsg server.
|
(package private) void |
thisServerCloudStatus(int status)
This method tells the server this server is connected to,
what cloud status this server has.
|
void |
unSendAndGet(int id)
Method to remove a previous sendAndGet to receive a message of a subject
and type from the domain server.
|
void |
unsubscribe(java.lang.String subject,
java.lang.String type,
java.lang.String namespace)
Method for a server to unsubscribe for messages of a subject
and type from another cMsg server.
|
void |
unsubscribeAndGet(java.lang.String subject,
java.lang.String type,
java.lang.String namespace,
cMsgCallbackInterface cb)
Method to remove a previous subscribeAndGet on another cMsg server.
|
cMsgServerClient client
java.lang.String serverName
public cMsgServerBridge(cMsgNameServer nameServer, java.lang.String serverName, int thisNsTcpPort, int thisNsUdpPort) throws cMsgException
nameServer
- THIS name server (the one using this object)serverName
- name of server to connect to in the form "host:port"thisNsTcpPort
- the TCP port THIS name server is listening onthisNsUdpPort
- the Udp multicast port THIS name server is listening oncMsgException
- if local host name cannot be foundpublic void printSizes()
public static cMsgCallbackAdapter getSubAndGetCallback()
public static cMsgCallbackAdapter getSendAndGetCallback(int id, int sysMsgId)
id
- incoming message's senderToken needs to be changed to this valuesysMsgId
- incoming message's sysMsgId needs to be changed to this valuepublic java.util.Set<java.lang.String> connect(boolean isOriginator, java.lang.String cloudPassword, java.lang.String clientPassword, boolean multicasting) throws cMsgException
isOriginator
- true if originating the connection between the 2 servers and
false if this is the response or reciprocal connectioncloudPassword
- password for connecting to a server in a particular cloudclientPassword
- password for a client connecting to this servermulticasting
- true if multicasting to find server since host unknowncMsgException
- if there are problems parsing the UDL or
communication problems with the serverpublic void setServerName(java.lang.String serverName)
serverName
- name of the server this bridge's client is connected to.int getCloudStatus()
cMsgNameServer.INCLOUD
,
cMsgNameServer.NONCLOUD
, orcMsgNameServer.BECOMINGCLOUD
.void setCloudStatus(int cloudStatus)
cMsgNameServer.INCLOUD
,
cMsgNameServer.NONCLOUD
, orcMsgNameServer.BECOMINGCLOUD
.cloudStatus
- cloud status of the server this is a bridge tovoid thisServerCloudStatus(int status) throws java.io.IOException
status
- cMsgNameServer.INCLOUD, .NONCLOUD, or .BECOMINGCLOUDjava.io.IOException
- if communication error with serverboolean cloudLock(int delay) throws java.io.IOException
delay
- time in milliseconds to wait for the lock before timing outjava.io.IOException
- if communication error with servervoid cloudUnlock() throws java.io.IOException
java.io.IOException
- if communication error with serverboolean registrationLock(int delay) throws java.io.IOException
delay
- time in milliseconds to wait for the lock before timing outjava.io.IOException
- if communication error with servervoid registrationUnlock() throws java.io.IOException
java.io.IOException
- if communication error with serverjava.lang.String[] getClientNamesAndNamespaces() throws java.io.IOException
java.io.IOException
- if communication error with serverpublic void subscribe(java.lang.String subject, java.lang.String type, java.lang.String namespace) throws java.io.IOException
subject
- message subjecttype
- message typenamespace
- message namespacejava.io.IOException
- there are communication problems with the serverpublic void unsubscribe(java.lang.String subject, java.lang.String type, java.lang.String namespace) throws java.io.IOException
subject
- message subjecttype
- message typenamespace
- message namespacejava.io.IOException
- there are communication problems with the serverpublic void sendAndGet(cMsgMessage msg, java.lang.String namespace, cMsgCallbackInterface cb) throws java.io.IOException
msg
- message sent to servernamespace
- message namespacecb
- callback for response to sendAndGet requestjava.io.IOException
- if there are communication problems with the serverpublic void unSendAndGet(int id) throws java.io.IOException
id
- receiverSubscribeId of original message sent in sendAndGetjava.io.IOException
- if there are communication problems with the serverpublic void subscribeAndGet(java.lang.String subject, java.lang.String type, java.lang.String namespace, cMsgCallbackInterface cb) throws java.io.IOException
subject
- subject of message desired from servertype
- type of message desired from servernamespace
- message namespacecb
- callbackjava.io.IOException
- there are communication problems with the serverpublic void unsubscribeAndGet(java.lang.String subject, java.lang.String type, java.lang.String namespace, cMsgCallbackInterface cb) throws java.io.IOException
subject
- subject of message desired from servertype
- type of message desired from servernamespace
- message namespacecb
- callbackjava.io.IOException
- there are communication problems with the serverpublic void shutdownClients(java.lang.String clientName, boolean includeMe) throws java.io.IOException
clientName
- client(s) to be shutdownincludeMe
- if true, it is permissible to shutdown calling clientjava.io.IOException
- if there are communication problems with the serverpublic void shutdownServer() throws java.io.IOException
java.io.IOException
- if there are communication problems with the server