public class ServerSocketPropagandist
extends java.util.Observable
implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
ServerSocketPropagandist(int a_portNumber) |
ServerSocketPropagandist(int a_portNumber,
InfoServiceDBEntry a_infoService)
Creates a new ServerSocketPropagandist.
|
Modifier and Type | Method and Description |
---|---|
private int |
announceNewForwarder()
This method announces the local forwarding server with the specified port to the specified
infoservice.
|
private int |
announceNewForwarder(InfoServiceDBEntry a_infoService) |
int |
getCurrentErrorCode()
Returns the error code of the last announcement try.
|
int |
getCurrentState()
Returns the current registration state at the infoservice.
|
InfoServiceDBEntry |
getInfoService() |
int |
getPort() |
private int |
renewForwarder()
This method renews our forwarding entry at the infoservice.
|
private int |
renewForwarder(InfoServiceDBEntry a_infoService) |
void |
run()
This is the implementation of the propaganda thread.
|
void |
stopPropaganda()
This will stop the propaganda thread.
|
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
public ServerSocketPropagandist(int a_portNumber)
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.public int getPort()
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 announceNewForwarder(InfoServiceDBEntry a_infoService)
private int renewForwarder()
private int renewForwarder(InfoServiceDBEntry a_infoService)
Copyright © 2023. All rights reserved.