ANSI C UA Server SDK  1.5.1.313
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
Session

Overview

The UaClient_Session structure represents a connection between the Client application and an individual Server. A process can create many Session objects connected to different Servers. The Session object is responsible for monitoring the connection with the Server and attempting to reconnect if there are any errors. The application can receive notifications of changes to the connection status through the callback UaClient_Session_ConnectionStatusChanged_CB.

A UaClient_Session object is not thread-safe and can only be used from within the main thread.

Connection Handling and Reconnect

The UaClient_Session_BeginConnect call establishes and maintains a Session with a Server.

After a successful connect, the connection is monitored by the SDK by using the Read service reading the status variable on the Server. The Read cycle time (UaClient_Session::WatchdogTime) and the timeout for the Read (UaClient_Session::WatchdogTimeout) can be configured at the Session object. The application can receive notifications of changes to the connection status through the callback UaClient_Session_ConnectionStatusChanged_CB. All reconnect handling is done by the SDK. The only case when the application may need additional handling is the case when it was necessary to create a new Session in the Server during the reconnect. This is indicated by the status UaClient_ConnectionStatus::UaClient_ConnectionStatus_SessionAutomaticallyRecreated. In this case, all registered nodes need to be reregistered and the namespace table should be read again.

If the initial connect fails or the connection gets interrupted, the SDK can be told to retry connecting by setting UaClient_Session::AutomaticReconnect to OpcUa_True.

Handles and IDs

SessionId

The SessionId is an internal Server created handle for communicating between Server and Client (SDK). Depending on the used protocol, the SessionId can be security relevant and should not be visible outside the Client or Server application.

UserData

The UaClient_Session::pUserData is a client (SDK user) defined pointer to arbitrary data. The SDK will never modify this member of the Session, so the user is responsible for freeing any memory associated with the pointer. The UserData can be used to distinguish Sessions in callback functions like UaClient_Session_ConnectionStatusChanged_CB.

The service user data (argument a_pUserData to every service call function) is a Client (SDK user) defined pointer to arbitrary data. The SDK will never modify or dereference this pointer, so the user is responsible for freeing any memory associated with the pointer. It can be used to distinguish service invocations that use the same callback function.