Kanzi Connect  3.9.2
Kanzi Connect Java API
KanziConnectContext Class Reference

Helper class for adapting Kanzi connect functionality into Android UI Application. More...

Public Member Functions

 KanziConnectContext ()
 Constructor that constructs object with default arguments.
 
 KanziConnectContext (ClientConnector connector)
 Constructs a kanzi connect context with existing client connector. More...
 
 KanziConnectContext (int loglevel)
 Constructs a kanzi connect context with client connector. More...
 
 KanziConnectContext (ClientConnector connector, int loglevel)
 Constructs a kanzi connect context with existing client connector. More...
 
ClientConnector getClientConnector ()
 Retrieve client connector. More...
 
ClientConnector.State getConnectionState ()
 Returns the current connection state. More...
 
boolean getLogging ()
 Retrieve state of logging. More...
 
UIThreadIntegrator getUIThreadIntegrator ()
 Retrieve Android UI Thread integration functionality. More...
 
boolean initialize (StringMap connectionAttributes, AbstractService service)
 Initialize the Connect context to run a remote service. More...
 
boolean initialize (StringMap connectionAttributes)
 Initialize the Connect context. More...
 
boolean isConnected ()
 Returns the current connection status whether connection has been established. More...
 
void setClientConnector (ClientConnector connector)
 Changes the client connector. More...
 
void setLogging (boolean enable)
 Enable/Disable logging. More...
 
void setUIThreadIntegrator (UIThreadIntegrator integrator)
 Changes the UI thread integrator at runtime for example when new one is created. More...
 
boolean start ()
 Starts connector operation. More...
 
void stop ()
 Stops the connector operation, will cause possible connection to get disconnected. More...
 
void uninitialize ()
 Cleanup the connector, will disconnect possible existing connections. More...
 

Detailed Description

Helper class for adapting Kanzi connect functionality into Android UI Application.

Enables running one remote service and any number of Kanzi Connect clients in Android UI thread.

Constructor & Destructor Documentation

◆ KanziConnectContext() [1/3]

KanziConnectContext ( ClientConnector  connector)

Constructs a kanzi connect context with existing client connector.

Parameters
connectorconnector instance

◆ KanziConnectContext() [2/3]

KanziConnectContext ( int  loglevel)

Constructs a kanzi connect context with client connector.

Parameters
loglevelthe logging level. 4 = trace 3 = info 2 = warning 1 = error
Note
Some loglevels might be disabled at compile time.

◆ KanziConnectContext() [3/3]

KanziConnectContext ( ClientConnector  connector,
int  loglevel 
)

Constructs a kanzi connect context with existing client connector.

Parameters
connectorconnector instance
loglevelLogging level for kanzi connect core library. 4 = trace 3 = info 2 = warning 1 = error
Note
Some loglevels might be disabled at compile time.

Member Function Documentation

◆ getClientConnector()

ClientConnector getClientConnector ( )

Retrieve client connector.

Returns
client connector instance.

◆ getConnectionState()

ClientConnector.State getConnectionState ( )

Returns the current connection state.

Returns
connection state enumeration value

◆ getLogging()

boolean getLogging ( )

Retrieve state of logging.

Returns
true if logging is enabled.

◆ getUIThreadIntegrator()

UIThreadIntegrator getUIThreadIntegrator ( )

Retrieve Android UI Thread integration functionality.

Returns
Instance of UI thread integration functionality.

◆ initialize() [1/2]

boolean initialize ( StringMap  connectionAttributes,
AbstractService  service 
)

Initialize the Connect context to run a remote service.

Parameters
connectionAttributesconnection information, specifies the server to connect
servicethe service to run. can be null.
Returns
true if initialization started.

◆ initialize() [2/2]

boolean initialize ( StringMap  connectionAttributes)

Initialize the Connect context.

After successfull call it is possible to start the connector.

Parameters
connectionAttributesconnection information, specifies the server to connect
Returns
true if initialization started.

◆ isConnected()

boolean isConnected ( )

Returns the current connection status whether connection has been established.

For more detailed state information and receiving state change callbacks see ClientConnector class returned by getClientConnector() method.

Returns
true if currently connected.

◆ setClientConnector()

void setClientConnector ( ClientConnector  connector)

Changes the client connector.

Parameters
connectorconnector

◆ setLogging()

void setLogging ( boolean  enable)

Enable/Disable logging.

By default logging is enabled.

Parameters
enablenew state for logging.

◆ setUIThreadIntegrator()

void setUIThreadIntegrator ( UIThreadIntegrator  integrator)

Changes the UI thread integrator at runtime for example when new one is created.

Parameters
integratornew integrator.

◆ start()

boolean start ( )

Starts connector operation.

Connector tries to maintain connection towards the configured server.

Should be called only from android applications UI thread.

Returns
true if successfully started.

◆ stop()

void stop ( )

Stops the connector operation, will cause possible connection to get disconnected.

Should be called only from android applications UI thread.

◆ uninitialize()

void uninitialize ( )

Cleanup the connector, will disconnect possible existing connections.

After calling this new initialization is required before it is possible to start again.