TT Setup SDK (Developer Preview)  0.1
Documentation
Initializing a console application

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
{
// Add your app secret Key here. It looks like: 00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000
string appSecretKey = "Your App Key";
//Set the environment the app needs to run in here
tt_setup_sdk.ServiceEnvironment environment = tt_setup_sdk.ServiceEnvironment.UatCert;
environment,
appSecretKey);
// Start the TT API on the same thread
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
{
// Declare the API objects
private TTSetupSDK m_sdk = null;
private tt_setup_sdk.WorkerDispatcher m_disp = null;
public void Start(tt_setup_sdk.TTSetupSDKOptions apiConfig)
{
m_disp.DispatchAction(() =>
{
Init(apiConfig);
});
m_disp.Run();
}
public void Init(tt_setup_sdk.TTSetupSDKOptions apiConfig)
{
TTSetupSDKInitializeHandler apiInitializeHandler = new TTSetupSDKInitializeHandler(TTSetupSdkInitHandler);
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;
// Open a connection to TT Setup and authenticate your credentials
m_sdk.TTSetupSDKStatusUpdate += M_sdk_TTSetupSDKStatusUpdate;
m_sdk.Start();
}
else if (ex.IsRecoverable)
{
// Initialization failed but retry is in progress...
}
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)
{
// TODO: Do any clean up processing here
return;
}
// Status is up
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");
}
}
Copyright © 2019 Trading Technologies International, Inc