com.vodafone360.people.service.transport
Class ConnectionManager

java.lang.Object
  extended by com.vodafone360.people.service.transport.ConnectionManager
All Implemented Interfaces:
LoginEngine.ILoginEventsListener, IQueueListener

public class ConnectionManager
extends java.lang.Object
implements LoginEngine.ILoginEventsListener, IQueueListener

ConnectionManager - responsible for controlling the current connection Connects and disconnects based on network availability etc and start or stops RPG polling. Currently handles HTTP connections - this will be extended to support TCP sockets.


Field Summary
private  IConnection mConnection
           
private  DecoderThread mDecoder
           
private static ConnectionManager mInstance
           
private  RemoteService mService
           
 
Constructor Summary
private ConnectionManager()
           
 
Method Summary
 void connect(RemoteService service)
           
 void disconnect()
           
 void free()
          Note: only called from tests.
private  IConnection getAutodetectedConnection(RemoteService service)
          Returns an autodetected connection.
static ConnectionManager getInstance()
           
 void notifyOfItemInRequestQueue()
          Notifies the implementation that a new request is available in the queue and should trigger its delivery to the backend.
 void notifyOfUiActivity()
           
 void onLoginStateChanged(boolean loggedIn)
           
 void setTestConnection(IConnection testConn)
          Enable test connection (for Unit testing purposes)
private  void unsubscribeFromQueueEvents()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mInstance

private static ConnectionManager mInstance

mConnection

private IConnection mConnection

mService

private RemoteService mService

mDecoder

private DecoderThread mDecoder
Constructor Detail

ConnectionManager

private ConnectionManager()
Method Detail

getInstance

public static ConnectionManager getInstance()

connect

public void connect(RemoteService service)

getAutodetectedConnection

private IConnection getAutodetectedConnection(RemoteService service)
Returns an autodetected connection. Where available, TCP will be used. HTTP is used as a fallback alternative.

Returns:
Returns the correct implmentation of the connection. If TCP is available it will be used preferably. Otherwise, HTTP is used as a fallback.

disconnect

public void disconnect()

onLoginStateChanged

public void onLoginStateChanged(boolean loggedIn)
Specified by:
onLoginStateChanged in interface LoginEngine.ILoginEventsListener

notifyOfItemInRequestQueue

public void notifyOfItemInRequestQueue()
Description copied from interface: IQueueListener
Notifies the implementation that a new request is available in the queue and should trigger its delivery to the backend.

Specified by:
notifyOfItemInRequestQueue in interface IQueueListener

notifyOfUiActivity

public void notifyOfUiActivity()

unsubscribeFromQueueEvents

private void unsubscribeFromQueueEvents()

free

public void free()
Note: only called from tests.


setTestConnection

public void setTestConnection(IConnection testConn)
Enable test connection (for Unit testing purposes)

Parameters:
testConn - handle to test connection


JavaDoc