To create a Console application, you need to:
- Create an instance of the TTSetupSDKOptions class passing the TT environment to which your application will connect and your application key for this environment.
- Attach a worker dispatcher to the thread on which you will consume events and start it.
- Initialize TT Setup SDK.
- Authenticate your credentials.
The following code snippet demonstrates an example of this process.
class Program
{
static void Main(string[] args)
{
try
{
string appSecretKey = "Your App Key";
environment,
appSecretKey);
TTSetupSDKFunctions tf = new TTSetupSDKFunctions();
Thread workerThread = new Thread(() => tf.Start(apiConfig));
workerThread.Name = "TT Setup SDK Thread";
workerThread.Start();
while (true)
{
string input =
System.Console.ReadLine();
if (input == "q")
break;
}
tf.Dispose();
}
catch (Exception e)
{
Console.WriteLine(e.Message + "\n" + e.StackTrace);
}
}
}
public class TTSetupSDKFunctions
{
private TTSetupSDK m_sdk = null;
{
{
Init(apiConfig);
});
m_disp.Run();
}
{
TTSetupSDK.CreateTTSetupSDK(m_disp, apiConfig, apiInitializeHandler);
}
public void TTSetupSdkInitHandler(TTSetupSDK sdk, ApiCreationException ex)
{
if (ex == null)
{
Console.WriteLine("TT SETUP SDK Initialization Complete");
m_sdk = sdk;
m_sdk.TTSetupSDKStatusUpdate += M_sdk_TTSetupSDKStatusUpdate;
m_sdk.Start();
}
else if (ex.IsRecoverable)
{
}
else
{
Console.WriteLine("TT SETUP SDK Initialization Failed: {0}", ex.Message);
Dispose();
}
}
private void M_sdk_TTSetupSDKStatusUpdate(object sender, TTSetupStatusUpdateEventArgs e)
{
Console.WriteLine("TTSetupSDKStatusUpdate: {0}", e);
if (e.IsReady == false)
{
return;
}
Console.WriteLine("TT SETUP SDK Connected and Authenticated");
}
public void Dispose()
{
TTSetupSDK.ShutdownCompleted += TTSetupSDK_ShutdownCompleted;
TTSetupSDK.Shutdown();
}
public void TTSetupSDK_ShutdownCompleted(object sender, EventArgs e)
{
Console.WriteLine("TTSetupSDK Shutdown completed");
}
}