All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class SE.kth.speech.broker.BrokerClient

SE.kth.speech.broker.Connection
   |
   +----SE.kth.speech.broker.BrokerClient

public class BrokerClient
extends Connection
A client's connection to the broker.

Copyright 1997 Erland Lewin&npsb;(erl@speech.kth.se) and the Center for Speech Technology (CTT)

This is the only class the implementation of a Broker module should need.

Version:
1.1
See Also:
BrokerConnection

Constructor Index

 o BrokerClient(String, InetAddress, int)
Create a BrokerClient for a client that does not implement any functions of its own.
 o BrokerClient(String, InetAddress, int, ServiceProvider, boolean)
Create a BrokerClient which can be both take incoming calls and make outgoing calls.
 o BrokerClient(String, String, int)
Create a BrokerClient for a client that does not implement any functions of its own.
 o BrokerClient(String, String, int, ServiceProvider, boolean)
Create a BrokerClient which can be both take incoming calls and make outgoing calls, doing host-name lookup.
 o BrokerClient(String, String, String, ServiceProvider, boolean)
Create a BrokerClient which can be both take incoming calls and make outgoing calls, doing host-name lookup.

Method Index

 o callFunc(String, String)
Make a call to another Broker client, waiting for the result.
 o callFunc(String, Vector)
Make a MULTILINE call to another Broker client, waiting for the result.
 o callProc(String, String)
Make an asynchronous call to another Broker client.
 o connect()
Connect to the Broker.
 o disconnect()
Disconnect from the broker.
 o run()
Starts the thread that reads incoming data from the Broker.

Constructors

 o BrokerClient
 public BrokerClient(String clientName,
                     InetAddress brokerHost,
                     int brokerPort)
Create a BrokerClient for a client that does not implement any functions of its own. Note that the connections to the broker is not established until the connect method is called.

Parameters:
clientBaseName - The base name of the client. The client's real name will be assigned by the Broker when the client connects, probably by appending the host name and port number to the base name.
brokerHost - The host that the broker to connect to is running on.
brokerPort - The port number on the abovementioned host that the broker is on.
See Also:
connect
 o BrokerClient
 public BrokerClient(String clientBaseName,
                     String brokerHost,
                     int brokerPort)
Create a BrokerClient for a client that does not implement any functions of its own. This is constructor does the same as #BrokerClient(String,InetAddress,int) except that the host name is specified as a String rather as an InetAddress. Note that the connections to the broker is not established until the connect method is called.

Parameters:
clientBaseName - The base name of the client. The client's real name will be assigned by the Broker when the client connects, probably by appending the host name and port number to the base name.
brokerHost - The host that the broker to connect to is running on.
brokerPort - The port number on the abovementioned host that the broker is on.
See Also:
connect
 o BrokerClient
 public BrokerClient(String moduleName,
                     String hostName,
                     String portName,
                     ServiceProvider provider,
                     boolean serve) throws UnknownHostException, NumberFormatException
Create a BrokerClient which can be both take incoming calls and make outgoing calls, doing host-name lookup.

Parameters:
moduleName - The base name of the client. If the serve parameter is true, then this will be the final name. If it is false, then a unique name will be generated by the Broker when the client connects.
hostName - The host that the broker to connect to is running on. This constructor does the host-name lookup, and will throw an UnknownHostException if the specified host does not exist.
portName - The port number on the abovementioned host that the broker is on. If this string does not contain a valid number (according to Integer.parseInt) then a NumberFormatException will be thrown.
provider - The class which handles incoming calls.
serve - true if we are implementing a server, false otherwise. The only difference between clients and servers is that there can only be one server with a certain name, whereas clients are given a unique name every time they connect. Clients can receive incoming calls just like servers.
Throws: UnknownHostException
The specified host name cannot be resolved.
Throws: NumberFormatException
The supplied port number was not a valid number
See Also:
ServiceProvider, BrokerClient
 o BrokerClient
 public BrokerClient(String moduleName,
                     String hostName,
                     int portNumber,
                     ServiceProvider provider,
                     boolean serve) throws UnknownHostException
Create a BrokerClient which can be both take incoming calls and make outgoing calls, doing host-name lookup.

Parameters:
moduleName - The base name of the client. If the serve parameter is true, then this will be the final name. If it is false, then a unique name will be generated by the Broker when the client connects.
hostName - The host that the broker to connect to is running on. This constructor does the host-name lookup, and will throw an UnknownHostException if the specified host does not exist.
portName - The port number on the abovementioned host that the broker is on. If this string does not contain a valid number (according to Integer.parseInt) then a NumberFormatException will be thrown.
provider - The class which handles incoming calls.
serve - true if we are implementing a server, false otherwise. The only difference between clients and servers is that there can only be one server with a certain name, whereas clients are given a unique name every time they connect. Clients can receive incoming calls just like servers.
Throws: UnknownHostException
The specified host name cannot be resolved.
See Also:
ServiceProvider, BrokerClient
 o BrokerClient
 public BrokerClient(String n,
                     InetAddress h,
                     int p,
                     ServiceProvider bsp,
                     boolean serve)
Create a BrokerClient which can be both take incoming calls and make outgoing calls.

Parameters:
n - The base name of the client. If the serve parameter is true, then this will be the final name. If it is false, then a unique name will be generated by the Broker when the client connects.
h - The host that the broker to connect to is running on.
p - The port number on the abovementioned host that the broker is on.
bsp - The class which handles incoming calls.
serve - true if we are implementing a server, false otherwise. The only difference between clients and servers is that there can only be one server with a certain name, whereas clients are given a unique name every time they connect. Clients can receive incoming calls just like servers.
See Also:
BrokerClient, ServiceProvider

Methods

 o connect
 public void connect() throws ServerDownException, UnknownHostException, IOException
Connect to the Broker.

Throws: ServerDownException
There is no broker running on the specified server and port.
 o disconnect
 public void disconnect()
Disconnect from the broker.

 o run
 public void run()
Starts the thread that reads incoming data from the Broker. Should not be called from other classes. Implements the Runnable interface. The thread is started in the connect() method.

See Also:
connect
 o callProc
 public void callProc(String server,
                      String data) throws ServerDownException
Make an asynchronous call to another Broker client. Make a call without waiting for a result or error code. 'Fire and forget'. We must be connected to the Broker.

Parameters:
server - The Broker server to call.
data - The parameters to the call.
Throws: ServerDownException
The broker is no longer running
 o callFunc
 public Object callFunc(String server,
                        String data) throws BrokerException, ServerDownException
Make a call to another Broker client, waiting for the result. This call will block until it receives either a result or an error via the Broker.

Parameters:
server - The Broker server to call.
data - The parameters.
Returns:
Either a String (for an inline return) or a Vector of Strings (for multi-line return)
Throws: ServerDownException
The broker is no longer running
Throws: BrokerException
The call resulted in an error, or the server was not running, and could not be started
 o callFunc
 public Object callFunc(String server,
                        Vector data) throws BrokerException, ServerDownException
Make a MULTILINE call to another Broker client, waiting for the result. This call will block until it receives either a result or an error via the Broker.

Parameters:
server - The Broker server to call.
data - The parameters.
Returns:
Either a String (for an inline return) or a Vector of Strings (for multi-line return)
Throws: ServerDownException
The broker is no longer running
Throws: BrokerException
The call resulted in an error, or the server was not running, and could not be started

All Packages  Class Hierarchy  This Package  Previous  Next  Index