com.googlecode.android_scripting
Class SimpleServer

java.lang.Object
  extended by com.googlecode.android_scripting.SimpleServer
Direct Known Subclasses:
EventServer, JsonRpcServer

public abstract class SimpleServer
extends java.lang.Object

A simple server.

Author:
Damon Kohler (damonkohler@gmail.com)

Nested Class Summary
static interface SimpleServer.SimpleServerObserver
           
 
Constructor Summary
SimpleServer()
           
 
Method Summary
 void addObserver(SimpleServer.SimpleServerObserver observer)
          Adds an observer.
 int getNumberOfConnections()
          Returns the number of active connections to this server.
static java.net.InetAddress getPublicInetAddress()
           
 void removeObserver(SimpleServer.SimpleServerObserver observer)
          Removes an observer.
 void shutdown()
           
 java.net.InetSocketAddress startAllInterfaces(int port)
          data Starts the RPC server bound to all interfaces
 java.net.InetSocketAddress startLocal(int port)
          Starts the RPC server bound to the localhost address.
 java.net.InetSocketAddress startPublic(int port)
          data Starts the RPC server bound to the public facing address.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleServer

public SimpleServer()
Method Detail

addObserver

public void addObserver(SimpleServer.SimpleServerObserver observer)
Adds an observer.


removeObserver

public void removeObserver(SimpleServer.SimpleServerObserver observer)
Removes an observer.


getNumberOfConnections

public int getNumberOfConnections()
Returns the number of active connections to this server.


getPublicInetAddress

public static java.net.InetAddress getPublicInetAddress()
                                                 throws java.net.UnknownHostException,
                                                        java.net.SocketException
Throws:
java.net.UnknownHostException
java.net.SocketException

startLocal

public java.net.InetSocketAddress startLocal(int port)
Starts the RPC server bound to the localhost address.

Parameters:
port - the port to bind to or 0 to pick any unused port
Returns:
the port that the server is bound to

startPublic

public java.net.InetSocketAddress startPublic(int port)
data Starts the RPC server bound to the public facing address.

Parameters:
port - the port to bind to or 0 to pick any unused port
Returns:
the port that the server is bound to

startAllInterfaces

public java.net.InetSocketAddress startAllInterfaces(int port)
data Starts the RPC server bound to all interfaces

Parameters:
port - the port to bind to or 0 to pick any unused port
Returns:
the port that the server is bound to

shutdown

public void shutdown()