com.sentilla.host.client.interfaces
Class HostClientService

java.lang.Object
  extended by com.sentilla.host.client.interfaces.HostClientService
Direct Known Subclasses:
HostClient

public abstract class HostClientService
extends Object

HostClientService provides a framework of methods for managing communication with a Sentilla host server.

Author:
spence@sentilla.com

Field Summary
private static boolean DEBUG
           
 
Constructor Summary
HostClientService()
           
 
Method Summary
abstract  boolean connect()
          Attempt to open a socket connection to the host server This call will use the default server host and port, unless previously given in the HostClient constructor.
abstract  boolean connect(String host, int port)
          Attempt to open a socket connection to the host server using the given server host and port.
abstract  boolean connect(String host, int port, int timeout)
          Attempt to open a socket connection to the host server using the given server host, port and timeout.
abstract  void disconnect()
          Disconnect from the server
abstract  int getDebug()
          Get debug logging level
abstract  String getHost()
          Returns the current server hostname
abstract  int getPort()
          Returns the current server port
abstract  boolean isConnected()
          Is this HostClient currently connected to the server?
 Object processMessage(HostMessage msg)
          Method which handles actual command communication with the hostserver.
 Object processNetworkMessage(HostMessage msg)
          Method which handles actual network communication with the hostserver.
abstract  void setDebug(int debugLevel)
          Set debug logging level
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static boolean DEBUG
Constructor Detail

HostClientService

public HostClientService()
Method Detail

connect

public abstract boolean connect()
                         throws UnknownHostException,
                                IOException
Attempt to open a socket connection to the host server This call will use the default server host and port, unless previously given in the HostClient constructor.

Throws:
UnknownHostException
IOException

connect

public abstract boolean connect(String host,
                                int port)
                         throws UnknownHostException,
                                IOException
Attempt to open a socket connection to the host server using the given server host and port.

Parameters:
host - the host server address
port - the host server port number
Throws:
UnknownHostException
IOException

connect

public abstract boolean connect(String host,
                                int port,
                                int timeout)
                         throws UnknownHostException,
                                IOException
Attempt to open a socket connection to the host server using the given server host, port and timeout.

Parameters:
host - the host server address
port - the host server port number
timeout - the number of milliseconds to wait for a connection
Throws:
UnknownHostException
IOException

disconnect

public abstract void disconnect()
                         throws IOException
Disconnect from the server

Throws:
IOException

getHost

public abstract String getHost()
Returns the current server hostname

Returns:
String server hostname (or address)

getPort

public abstract int getPort()
Returns the current server port

Returns:
int server port

setDebug

public abstract void setDebug(int debugLevel)
Set debug logging level


getDebug

public abstract int getDebug()
Get debug logging level


isConnected

public abstract boolean isConnected()
Is this HostClient currently connected to the server?

Returns:
boolean returns true if connected, false otherwise

processMessage

public Object processMessage(HostMessage msg)
                      throws IOException
Method which handles actual command communication with the hostserver. The message object parameter is used for both sending the request, and receiving the server response.

Parameters:
msg - the message object to send to the server.
Returns:
returns the same message object, containing the server response.
Throws:
IOException - throws IOException on communication errors

processNetworkMessage

public Object processNetworkMessage(HostMessage msg)
                             throws IOException
Method which handles actual network communication with the hostserver. Messages which either communicate with mote networks, or manage network communication, are handled by this method. The message object parameter is used for both sending the request, and receiving the server response.

Parameters:
msg - the message object to send to the server.
Returns:
returns the same message object, containing the server response.
Throws:
IOException - throws IOException on communication errors


Copyright © 2007 Sentilla, Inc. All Rights Reserved.