com.sentilla.host.client
Class HostClient

java.lang.Object
  extended by com.sentilla.host.client.interfaces.HostClientService
      extended by com.sentilla.host.client.HostClient

public class HostClient
extends HostClientService

HostClient encapsulates all communication with a host server, which provides all connectivity to mote networks, and maintains network state.

Author:
spence@sentilla.com

Field Summary
private static ClientRadioProtocol clientRadioProtocol
           
private static Dispatcher dispatcher
           
private  String host
           
private  int port
           
static String SLINGSHOT_BIN_DIR
           
private  int timeout
           
 
Constructor Summary
HostClient()
          Create a HostClient.
 
Method Summary
 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.
 boolean connect(String host, int port)
          Attempt to open a socket connection to the host server using the given server host and port.
 boolean connect(String host, int port, int timeout)
          Attempt to open a socket connection to the host server using the given server host and port.
 void disconnect()
          Disconnect from the server
 ApplicationServiceImpl getApplicationService()
          Return an ApplicationServiceImpl client object for managing mote applications.
 int getDebug()
          Get debug logging level
 String getHost()
          Returns the current server hostname
 int getPacketsRead()
          Returns the number packets read from the server since instantiation, or the last reset.
 int getPacketsWritten()
          Returns the number packets written to the server since instantiation, or the last reset.
 int getPort()
          Returns the current server port
 ServerAdminClientImpl getServerAdminClient()
          Return a ServerAdmin client object for server administration.
private  void initDispatcher(String host, int port)
          Initialize dispatcher.
 boolean isConnected()
          Is this HostClient currently connected to the server?
 void setDebug(int debugLevel)
          Set debug logging level
 
Methods inherited from class com.sentilla.host.client.interfaces.HostClientService
processMessage, processNetworkMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SLINGSHOT_BIN_DIR

public static final String SLINGSHOT_BIN_DIR

host

private String host

port

private int port

timeout

private int timeout

clientRadioProtocol

private static ClientRadioProtocol clientRadioProtocol

dispatcher

private static Dispatcher dispatcher
Constructor Detail

HostClient

public HostClient()
Create a HostClient.

Method Detail

connect

public 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.

Specified by:
connect in class HostClientService
Throws:
UnknownHostException
IOException

connect

public 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.

Specified by:
connect in class HostClientService
Parameters:
host - the host server address
port - the host server port number
Throws:
UnknownHostException
IOException

connect

public 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 and port.

Specified by:
connect in class HostClientService
Parameters:
host - the host server address
port - the host server port number
timeout - the max milliseconds to wait for server communication
Throws:
UnknownHostException
IOException

initDispatcher

private void initDispatcher(String host,
                            int port)
                     throws UnknownHostException,
                            IOException
Initialize dispatcher.

Throws:
IOException
UnknownHostException

disconnect

public void disconnect()
                throws IOException
Disconnect from the server

Specified by:
disconnect in class HostClientService
Throws:
IOException

isConnected

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

Specified by:
isConnected in class HostClientService
Returns:
boolean returns true if connected, false otherwise

getHost

public String getHost()
Returns the current server hostname

Specified by:
getHost in class HostClientService
Returns:
String server hostname (or address)

getPort

public int getPort()
Returns the current server port

Specified by:
getPort in class HostClientService
Returns:
int server port

setDebug

public void setDebug(int debugLevel)
Set debug logging level

Specified by:
setDebug in class HostClientService

getDebug

public int getDebug()
Get debug logging level

Specified by:
getDebug in class HostClientService

getApplicationService

public ApplicationServiceImpl getApplicationService()
Return an ApplicationServiceImpl client object for managing mote applications.

Returns:
ApplicationServiceImpl a handle to an ApplicationService object

getServerAdminClient

public ServerAdminClientImpl getServerAdminClient()
Return a ServerAdmin client object for server administration.

Returns:
ServerAdminClientImpl a handle to a ServerAdmin object

getPacketsRead

public int getPacketsRead()
Returns the number packets read from the server since instantiation, or the last reset.

Returns:
int the number of packets read from the server

getPacketsWritten

public int getPacketsWritten()
Returns the number packets written to the server since instantiation, or the last reset.

Returns:
int the number of packets written to the server


Copyright © 2007 Sentilla, Inc. All Rights Reserved.