|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Observable forward.server.ServerSocketPropagandist
public class ServerSocketPropagandist
This class registers the port of a ServerSocketManager at the infoservice (the IP is detected by the infoservice). So the blockees can find that interface and can connect to. This class is also observable. When the registration state or the current error code changes, the observers are notified (there is no message sent -> message = null). See the STATE and RETURN constants and the getCurrentState() and getCurrentErrorCode() method for more information.
Field Summary | |
---|---|
private static int |
FORWARDER_RENEW_ERROR_CODE
This is the error code the infoservice returns, if the registration was lost and the infoservice doesn't know any mor our forwarding id. |
private static long |
FORWARDER_RENEW_PERIOD
The period in milliseconds for renewing the forwarder entry at the infoservice. |
private static int |
FORWARDER_VERIFY_ERROR_CODE
This is the error code the infoservice returns, if verifying of our forwarding server was not successful. |
private int |
m_currentConnectionState
Stores the current connection state. |
private int |
m_currentErrorCode
Stores the error code of the first announcement try. |
private java.lang.String |
m_forwarderId
Stores our by the infoservice assigned id, if the announcement was successful. |
private InfoServiceDBEntry |
m_infoService
Stores the infoservice where we have to announce the local port number. |
private int |
m_portNumber
Stores the local port nmuber which we have to announce to the infoservice. |
private java.lang.Thread |
m_propagandaThread
Stores the instance of the propaganda thread. |
private static int |
RETURN_FORWARDERID_ERROR
This value is returned, if renewing of our forwarding entry fails at the infoservice because the infoservice does not know our forwarder id any more. |
static int |
RETURN_INFOSERVICE_ERROR
This value is returned, if we could not reach the infoservice or the infoservice has no forwarder list. |
static int |
RETURN_SUCCESS
This value is returned, if announcing or renewing of the forwarder entry at the infoservice was successful. |
static int |
RETURN_UNKNOWN_ERROR
This value is returned, if there was an unexpected error while infoservice communication. |
static int |
RETURN_VERIFICATION_ERROR
This value is returned, if the infoservice could not verify the local forwarding server. |
static int |
STATE_CONNECTING
This is the state, when we were never registered at the infoservice and we are trying to register the first time. |
static int |
STATE_HALTED
This is the state, when the propaganda thread was stopped. |
static int |
STATE_RECONNECTING
This is the state, when we were already registered at the infoservice, but the registration was lost and we are trying to register again. |
static int |
STATE_REGISTERED
This is the state, when we are registerd at the infoservice. |
Constructor Summary | |
---|---|
ServerSocketPropagandist(int a_portNumber,
InfoServiceDBEntry a_infoService)
Creates a new ServerSocketPropagandist. |
Method Summary | |
---|---|
private int |
announceNewForwarder()
This method announces the local forwarding server with the specified port to the specified infoservice. |
int |
getCurrentErrorCode()
Returns the error code of the last announcement try. |
int |
getCurrentState()
Returns the current registration state at the infoservice. |
InfoServiceDBEntry |
getInfoService()
Returns the infoservice, where this propagandist is trying to get registrated. |
private int |
renewForwarder()
This method renews our forwarding entry at the infoservice. |
void |
run()
This is the implementation of the propaganda thread. |
void |
stopPropaganda()
This will stop the propaganda thread. |
Methods inherited from class java.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int STATE_REGISTERED
public static final int STATE_CONNECTING
public static final int STATE_RECONNECTING
public static final int STATE_HALTED
public static final int RETURN_SUCCESS
public static final int RETURN_VERIFICATION_ERROR
public static final int RETURN_INFOSERVICE_ERROR
public static final int RETURN_UNKNOWN_ERROR
private static final int RETURN_FORWARDERID_ERROR
private static final int FORWARDER_VERIFY_ERROR_CODE
private static final int FORWARDER_RENEW_ERROR_CODE
private static final long FORWARDER_RENEW_PERIOD
private int m_portNumber
private InfoServiceDBEntry m_infoService
private java.lang.String m_forwarderId
private int m_currentErrorCode
private java.lang.Thread m_propagandaThread
private int m_currentConnectionState
Constructor Detail |
---|
public ServerSocketPropagandist(int a_portNumber, InfoServiceDBEntry a_infoService)
a_portNumber
- The port number of a local ServerSocketManager.a_infoService
- The infoservice (which must have a forwarder list) where we shall get
registered.Method Detail |
---|
public void stopPropaganda()
public int getCurrentState()
public int getCurrentErrorCode()
public InfoServiceDBEntry getInfoService()
public void run()
run
in interface java.lang.Runnable
private int announceNewForwarder()
private int renewForwarder()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |