Simple |
Connect to the specified server.
Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public ConnectionResult Connect( Uri serverUrl, string userName, string password, out ConnectionInfoV1 connectionInfo )
Parameters
- serverUrl Uri
- Use the server URL in format "https://[ipAddress]:[port]/" in case that connectorName is ConnectorConfiguration.RestClient, and in format "[full path to the file where json files are located]" in case that connectorName is ConnectorConfiguration.FileConnector.
- userName String
- Name of the user.
- password String
- The password.
- connectionInfo ConnectionInfoV1
- Connection Info. When connect not successful, returns null
Return Value
ConnectionResultConnection result
Exceptions
| Exception | Condition |
|---|---|
| ValidationException |
Example
The following example illustrates how the SimpleClient connects to the C4 server with RestClient.
C#
using Gamanet.C4.SDK; using Gamanet.C4.SimpleInterfaces; using System; public class RestClientConnect { static void Main() { // Create instance of simple client with configuration for RestClient (connection to C4 server) var client = new SimpleClient(ConnectorConfiguration.HttpClient); ConnectionInfo token; // connecting in case the server is not accessible or ip address is wrong var connectionResult = client.Connect(new Uri("https://wrongAddress/"), "Support", "support", out token); Console.WriteLine("Connection result: {0}", connectionResult); // connecting in case that a credential is invalid connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "WrongPassword", out token); Console.WriteLine("Connection result: {0}", connectionResult); // connecting in case the server is accessible and credential for connect is valid connectionResult = client.Connect(new Uri("https://localhost/"), "Support", "support", out token); Console.WriteLine("Connection result: {0}", connectionResult); // The example displays the following output: // Connection result: UnreachableServer // Connection result: InvalidCredentials // Connection result: Successful } }
See Also