ClientConnector¶
-
class
kanzi::connect
::
ClientConnector
¶ Base connector.
Public Types
-
typedef enum kanzi::connect::ClientConnector::P2PAttribute
P2PAttribute
-
typedef enum kanzi::connect::ClientConnector::RunMode
RunMode
-
enum
State
¶ Values:
-
enumerator
NotPrepared
¶
-
enumerator
WaitingReconnect
¶ While this state is reported, client can safely reconfigure the connection parameters and those will be taken into use on next connection try.
-
enumerator
Connecting
¶
-
enumerator
Connected
¶
-
enumerator
RegisteringService
¶
-
enumerator
Disconnected
¶
-
enumerator
-
typedef enum kanzi::connect::ClientConnector::State
State
Public Functions
-
ClientConnector
(const string &configurationFile = string())¶ Constructor.
- Parameters
configurationFile – optinal (server) configuration file that specifies policy related configurations. Nothing else is taken into account from the passed in configuration file. To be used when running remote service using the connector
-
virtual
~ClientConnector
()¶ Destructor.
-
void
addStateChangeCallback
(StateCallback *callback)¶ Adds a traditional callback interface that is invoked when connector state changes.
- Parameters
callback – to be invoked.
-
bool
configureP2PAttribute
(P2PAttribute attribute, const string &attributeValue)¶ Configures a free form P2P attribute.
- Parameters
attribute – the identifier of the attribute to configure.
attributeValue – the value for the attribute
- Returns
true if attribute was recognized and usable.
-
int
getAutomaticReconnectInterval
() const¶ Retrieve automatic reconnect interval.
- Returns
milliseconds how fast after reconnect the connection reconnect is tried.
-
ClientSharedPtr
getClient
()¶ Retrieve the contained client instance.
- Returns
client instance.
-
RemoteContentClientSharedPtr
getContentClient
()¶ Retrieve the content client for this connector.
- Returns
content client.
-
inline ConnectDomain *
getDomain
() const¶ Retrieve domain.
- Returns
domain
-
ClientRemoteServiceHost &
getRemoteServiceHost
()¶ Retrieve the contained remote service host instance.
- Returns
remote service host instance.
-
ClientConnector::RunMode
getRunMode
() const¶ Return the runmode of the connector.
- Returns
run mode that define how the connector works.
-
ClientConnector::State
getState
() const¶ Return the state of operation.
- Returns
the state of operation
-
VirtualFileRemoteClientSharedPtr
getVirtualFileClient
()¶ Retrieve the virtual file client that can be used to shared content via http.
- Returns
shared pointer to object.
-
WorkQueueInterface *
getWorkQueueEx
()¶ Retrieve the contained work queue Note: for android convenience, getRemoteServiceHost returns the same instance but with accurate cast.
- Returns
The work queue where its possible to add work items
Configures the connector with given arguments.
- Parameters
adapter – the connection adapter to be used
parameters – adapter specific parameters.
service – optional service that is run on this device.
-
void
performAsyncWork
()¶ This should be invoked, in application main thread context, as result to workAvailable callback.
the method implementation will check the calling thread and it must be the same used to call startAsync method.
-
void
removeStateChangeCallback
(StateCallback *callback)¶ Removes a traditional callback interface that is invoked when connector state changes.
- Parameters
callback – to be invoked.
-
void
setAutomaticReconnectInterval
(int milliseconds)¶ Automatic reconnection interval.
- Parameters
milliseconds – how long to wait, after detected disconnect, to reconnect. If negative value passed then reconnect functionality is not enabled and after disconnect the
-
void
setConnectionParameters
(const ClientConnectionAdapter::Parameters ¶meters)¶ Can change connection parameters while connector is running.
Changes will affect on next time when connecting.
Sets the service to connector.
This method can be successfully called only when connector has not been started yet. Passing service with initialize will override the service set with this method. Calling stop method will clear the previously configure service.
- Parameters
service – the service to set.
- Returns
true if service was cached, false on problems.
-
bool
startAsync
(Connection::WorkNotifyCallback *callback)¶ Starts asynchronous operation of the client connector.
Client connector will maintain server connection in a background. This method is intended to be used with external language bindings (Android) where the connect mainloop is run as part of android applications main loop.
- Parameters
callback – interface that is invoked when there is known to be data to process.
- Returns
true if operation started, false if could not be started.
-
bool
startSync
(int periodMs, ExternalControlCallback *callback = nullptr)¶ Runs continuously until explicitly stopped with stopRun() method.
- Parameters
periodMs – how often to manually executed background work regarless of whether we receive any signals about work availability. Note, in case the hosted service uses timers (AbstractService::setTimer) the period given here defines the worst case granularity for the timers used by the service.
- Returns
true if loop actually got run. false if initialization failed.
-
void
stop
()¶ Aborts either asynchronous or synchronous running of connector.
-
void
stopRun
()¶ Aborts either asynchronous or synchronous running of connector.
-
void
uninitialize
()¶ Unprepares the connector.
-
class
ExternalControlCallback
¶ Callback interface thta can be used to stop a synchronous loop.
-
class
StateCallback
¶ Callback interface from client connector(s)
Public Functions
-
inline virtual
~StateCallback
()¶ virtual destructor for SWIG.
-
virtual void
stateChanged
(ClientConnector::State state) = 0¶ Invoked when state changes.
- Parameters
state – the new state.
-
inline virtual
-
typedef enum kanzi::connect::ClientConnector::P2PAttribute