Package org.astrogrid.samp.bridge
Class Bridge
java.lang.Object
org.astrogrid.samp.bridge.Bridge
Runs a bridging service between two or more hubs.
For each client on one hub, a proxy client appears on all other
participating hubs. These proxies can be treated in exactly the
same way as normal clients by other registered clients; any
messages sent to/from them will be marshalled over the bridge
in a transparent way. One application for this is to allow
collaboration between users who each have their own hub running.
A notifyAll
call is made on
the Bridge object whenever the number of live hubs connected by
the bridge changes.
- Since:
- 15 Jul 2009
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
exportUrls
(int index, String host) Sets up a URL exporter for one of the hubs.Returns the hub connectors representing the bridge client running on each linked hub.Returns the client profiles which define the hubs this bridge links.static void
Main method.static int
Does the work for the main method.boolean
start()
Starts this bridge running.void
stop()
Stops this bridge running.
-
Constructor Details
-
Bridge
Constructor.- Parameters:
profiles
- array of SAMP profile objects, one for each hub which is to participate in the bridge- Throws:
IOException
-
-
Method Details
-
getProfiles
Returns the client profiles which define the hubs this bridge links.- Returns:
- profile array, one for each connected hub
-
getBridgeClients
Returns the hub connectors representing the bridge client running on each linked hub. Note this does not include any proxy clients, only the one-per-hub manager clients.- Returns:
- array of bridge manager clients, one for each hub (in corresponding positions to the profiles)
-
exportUrls
Sets up a URL exporter for one of the hubs. This will attempt to edit transmitted data contents for use in remote contexts; the main job is to adjust loopback host references in URLs (127.0.0.1 or localhost) to become fully qualified domain names for non-local use. It's not an exact science, but a best effort is made.- Parameters:
index
- index of the profile for which to export URLshost
- the name substitute for loopback host identifiers on the host on which that profile's hub is running
-
start
public boolean start()Starts this bridge running.- Returns:
- true iff all the participating hubs have been contacted successfully
-
stop
public void stop()Stops this bridge running. All associated manager and proxy clients are unregistered. -
main
Main method. Runs a bridge.- Throws:
IOException
-
runMain
Does the work for the main method. Use -help flag.- Throws:
IOException
-