API Support Forum
User Profile

Viewing User Profile for: CCedrick


About

Mar 16, 2010 07:09 AM

Mar 16, 2010 07:28 PM

Mar 20, 2010 07:06 PM



Post Statistics
CCedrick has contributed to 1 posts out of 5593 total posts (0.02%) in 5160 days (0.00 posts per day).

20 most recent posts:

API Support » Newbie: onLoginComplete not being called after logging on Mar 16, 2010 @ 07:28 PM (Total replies: 1)

Hi-

I have a console app written with the API DLL's from the Full Executable example. Here's my issue: I connect to OEC (at least the oecClient.Connect(...) doesn't throw an exception. However, after this nothing happens. I have added the event listeners for the most relevant events such as onLoginComplete, etc.. but they never get called. It just sits there.

The Full API examples, however do work. Is there a workaround? I have included my (somewhat) self-contained example below. Also, the app stays open, in my main class I wait for myself to press 'q' before calling a disconnect() method:

using System;
using System.Collections.Generic;
using System.Text;

using OEC.API;

namespace OECTest
{
public class OECTestClass
{

private OECClient oecClient = new OECClient();

public OECTestClass()
{

this.initializeOEC();

}

private void initializeOEC() {
this.oecClient.EventBatchInterval = 0;
this.oecClient.PriceHost = "";
this.oecClient.RemoteHostingEnabled = false;
this.oecClient.OnLoginComplete += new OnLoginCompleteEvent(oecClient_OnLoginComplete);
this.oecClient.OnLoginFailed += new OnLoginFailedEvent(oecClient_OnLoginFailed);
this.oecClient.OnDisconnected += new OnDisconnectedEvent(oecClient_OnDisconnected);
this.oecClient.OnPriceChanged += new OnPriceChangedEvent(oecClient_OnPriceChanged);

this.logonOEC();

}

private void logonOEC()
{
Console.WriteLine("Attempting To Connect to OEC, User-{0}", "myusername");
try
{
this.oecClient.Connect("api.openecry.com", 9200, "myusername", "mypassword", false);

Console.WriteLine("Connected to OEC. Waiting to perform post connection events");

//this line prints. After that, nothing.

}
catch (Exception ex)
{
Console.WriteLine("An exception happened trying to connect: {0}", ex.ToString());
}

}

private void subscribeToOECContracts()
{
Contract ctr = oecClient.Contracts["ESH0"];
this.oecClient.Subscribe(ctr);
Console.WriteLine("Subscribed to ESH0");

}



void oecClient_OnPriceChanged(Contract Contract, Price Price)
{
Console.WriteLine("Price Changed {0}", Contract.Symbol);
sendPriceUpdate(Contract.Symbol, Price);
}

void oecClient_OnDisconnected(bool Unexpected)
{
Console.WriteLine("Disconnected From OEC.");
}

void oecClient_OnLoginFailed(OEC.Data.FailReason Reason)
{
Console.WriteLine("OEC Logon Failed. Reason: {0}", Reason.ToString());
}

void oecClient_OnLoginComplete()
{
Console.WriteLine("Successfully Connected to OEC");
Console.WriteLine("Subscribing to Market Data");
subscribeToOECContracts();
}

public void disconnectAdapters()
{
oecClient.Disconnect();

Console.WriteLine("Disconnected from OEC: {0}", oecClient.ConnectionClosed);

}

}
}

Cedrick Johnson