Package org.astrogrid.samp.bridge
Class Bridge
- java.lang.Object
-
- org.astrogrid.samp.bridge.Bridge
-
public class Bridge extends java.lang.Object
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 Constructor Description Bridge(ClientProfile[] profiles)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
exportUrls(int index, java.lang.String host)
Sets up a URL exporter for one of the hubs.HubConnector[]
getBridgeClients()
Returns the hub connectors representing the bridge client running on each linked hub.ClientProfile[]
getProfiles()
Returns the client profiles which define the hubs this bridge links.static void
main(java.lang.String[] args)
Main method.static int
runMain(java.lang.String[] args)
Does the work for the main method.boolean
start()
Starts this bridge running.void
stop()
Stops this bridge running.
-
-
-
Constructor Detail
-
Bridge
public Bridge(ClientProfile[] profiles) throws java.io.IOException
Constructor.- Parameters:
profiles
- array of SAMP profile objects, one for each hub which is to participate in the bridge- Throws:
java.io.IOException
-
-
Method Detail
-
getProfiles
public ClientProfile[] getProfiles()
Returns the client profiles which define the hubs this bridge links.- Returns:
- profile array, one for each connected hub
-
getBridgeClients
public HubConnector[] 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
public void exportUrls(int index, java.lang.String host)
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
public static void main(java.lang.String[] args) throws java.io.IOException
Main method. Runs a bridge.- Throws:
java.io.IOException
-
runMain
public static int runMain(java.lang.String[] args) throws java.io.IOException
Does the work for the main method. Use -help flag.- Throws:
java.io.IOException
-
-