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, SecureString password, out ConnectionInfoV1 connectionInfo )
Parameters
- serverUrl Uri
- The server URL.
- userName String
- Name of the user.
- password SecureString
- The password.
- connectionInfo ConnectionInfoV1
- The connection information.
Return Value
ConnectionResultConnection result
Example
The following example illustrates how the SimpleClient connects to the C4 server with RestClient with secure string.
C#
using Gamanet.C4.SDK; using Gamanet.C4.SimpleInterfaces; using System; using System.Security; public class RestClientConnectWithSecureString { static void Main() { // Create instance of simple client with configuration for RestClient (connection to C4 server) var client = new SimpleClient(ConnectorConfiguration.HttpClient); var pass = "support"; // Instantiate the secure string. SecureString password = new SecureString(); // Assign the string to the secure string. foreach (char ch in pass) password.AppendChar(ch); pass = "wrongPass"; // Instantiate the secure string. SecureString wrongPassword = new SecureString(); // Assign the string to the secure string. foreach (char ch in pass) wrongPassword.AppendChar(ch); ConnectionInfo token; // connecting in case the server is not accessible or ip address is wrong var connectionResult = client.Connect(new Uri("https://wrongAddress/"), "Support", password, 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", password, out token); Console.WriteLine("Connection result: {0}", connectionResult); Console.ReadLine(); // The example displays the following output: // Connection result: UnreachableServer // Connection result: InvalidCredentials // Connection result: Successful } }
See Also