Client class
- Last UpdatedJun 18, 2025
- 2 minute read
Create a new client instance
Syntax
public Client()
Description
Creates a new Client instance.
Initialize the client
Syntax
public bool Initialize(string ScopeName, string serverMachineName)
Description
Initializes the client to connect to the specified Gateway Communication Driver instance on the specified computer. See the Gateway Communication Driver User Guide for details about how to specify the instance to which you want to connect.
The client retries a call to the server up to 12 times, with each connection attempt separated by a 25 second interval. If the specified OPC UA server name does not exist, or if the client cannot connect for another reason, the client shows a message that it is unable to connect to the endpoint. If you have specified an invalid OPC UA server name, you must close the connection to the invalid server name and create a new connection using the correct server name. Be sure to verify the server name to avoid retrying with the wrong server name.
Close the client
Syntax
public void Close()
if (client == null or client.IsConnected == false) then
' Close/Cleanup existing client if it is not connected to the server anymore
if (client <> null) then
client.Close();
endif;
' Create a Method client instance and connect to the server
client = CreateMethodClient(me.IMethodScope,me.GatewayServer);
endif;
Description
Closes the client and disconnects from the server. Use the if(client<>null) statement to disable the retry mechanism.
Call a method
Syntax
public MethodCallStatus CallMethod(string sourceId, string nodeId, string methodName, string userName, MethodArgument[] inputArgs)
Description
Calls the specified method.
See the Gateway Communication Driver User Guide for details about specifying sourceId and nodeId. See the MethodArgument class for details on how to construct/deconstruct method arguments.