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

To create a UI 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 UI dispatcher to the UI 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.

// ...
// ...
static class Program
{
[STAThread]
static void Main()
{
using (Dispatcher disp = Dispatcher.AttachUIDispatcher())
{
Application.EnableVisualStyles();
// Create an instance of the API
MyApp myApp = new MyApp();
// 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);
TTSetupSDKInitializeHandler apiInitializeHandler = new TTSetupSDKInitializeHandler(TTSetupSdkInitHandler);
TTSetupSDK.CreateTTSetupSDK(disp, apiConfig, apiInitializeHandler);
Application.Run(myApp);
}
}
}
// ...
// ...
public partial class MyApp : Form
{
// Declare the API objects
private TTSetupSDK m_sdk = null;
private bool m_isShutdown = false, m_shutdownInProcess = false;
public MyApp()
{
InitializeComponent();
}
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
{
MessageBox.Show("API Initialization Failed: " + ex.Message);
}
}
public 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;
}
// TT SETUP SDK Connected and Authenticated
// ...
}
public void shutdownTTSetupSDK()
{
if (!m_shutdownInProcess)
{
TTSetupSDK.ShutdownCompleted += new EventHandler(TTSetupSDK_ShutdownCompleted);
TTSetupSDK.Shutdown();
m_shutdownInProcess = true;
}
}
public void TTSetupSDK_ShutdownCompleted(object sender, EventArgs e)
{
m_isShutdown = true;
Close();
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
if (!m_isShutdown)
{
e.Cancel = true;
shutdownTTSetupSDK();
}
else
{
base.OnFormClosing(e);
}
}
}
Copyright © 2019 Trading Technologies International, Inc