Kanzi Connect  3.9.5
Kanzi Connect Java API
KanziConnectThreadRunner Class Reference

Helper class to run Kanzi Connect remote service, and possible service clients in custom thread. More...

Inheritance diagram for KanziConnectThreadRunner:
[legend]

Public Member Functions

 KanziConnectThreadRunner (Context context)
 Constructor. More...
 
 KanziConnectThreadRunner (Context context, int loglevel)
 Constructor. More...
 
ClientConnector getClientConnector ()
 Retrieve client connector. More...
 
ClientConnector.State getConnectionState ()
 Returns the current connection state. More...
 
boolean getLogging ()
 Retrieve state of logging. More...
 
Looper getLooper ()
 Retrieve the looper of the thread. 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 run ()
 
void setLogging (boolean enable)
 Enable/Disable logging. More...
 
boolean stopLooper ()
 Stops the thread in safe manner. More...
 

Detailed Description

Helper class to run Kanzi Connect remote service, and possible service clients in custom thread.

Allows very limited control to functionality so in case more complex operation is required this class can be customized accordingly.

This should be used in scenario when UI interaction is not required.

Constructor & Destructor Documentation

◆ KanziConnectThreadRunner() [1/2]

KanziConnectThreadRunner ( Context  context)

Constructor.

Parameters
contextthe context for service.

◆ KanziConnectThreadRunner() [2/2]

KanziConnectThreadRunner ( Context  context,
int  loglevel 
)

Constructor.

Parameters
contextthe context for service.
loglevellogging level for kanzi connect core library 4 = trace 3 = info 2 = warning 1 = error

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.

◆ getLooper()

Looper getLooper ( )

Retrieve the looper of the thread.

Returns
the looper

◆ 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 succeeded.

◆ 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.

◆ setLogging()

void setLogging ( boolean  enable)

Enable/Disable logging.

By default logging is enabled.

Parameters
enablenew state for logging.

◆ stopLooper()

boolean stopLooper ( )

Stops the thread in safe manner.

Use this always to stop the functionality and do not call Thread.stop() to stop it.