Note that there are some explanatory texts on larger screens.

plurals
  1. POVB.NET API Delegates and Events
    text
    copied!<p>I am stuck trying to work out Events and Delegates. I am trying to hook up to an external API which returns events when certain events occur. The original code was written in C#, and I am trying to do this in VB.NET.</p> <p>Here is a short comment from the API programmers.</p> <blockquote> <p>"After that, client app should need to wait for one of events: OnLoginComplete or OnLoginFailed In cause of succesfull login, all collections is already populated with session data (order states and fills, account positions), so application could display it on the GUI. If by some reason connection is dropped, OnDisconnected event would be fired immediately, notifying the client that requests couldn't be processed until connection is restored.<br> On a successfull logon system is ready to process client requests: subscriptions to price feeds and order requests. "</p> </blockquote> <p>I am trying to get the OnLoginFailed event to fire but are having just too many issues not sure how to do this, spent many hours trying to work it out.</p> <p>Here is a short note from the API Documentation.</p> <blockquote> <p><code>OECClient.OnLoginFailed</code> Event<br> Raised when connection couldn't be establised, credentials are wrong or client API version is invalid.</p> </blockquote> <pre><code>public event OnLoginFailedEvent OnLoginFailed; </code></pre> <blockquote> <p><code>OnLoginFailedEvent</code> Delegate<br> Occurs when connection failed to be established</p> </blockquote> <pre><code>public delegate void OnLoginFailedEvent( FailReason Reason ); </code></pre> <p>And here is my code in VB.net, I feel that I am close but just can't get it.</p> <pre><code>Imports OEC.API Imports OEC.CommLib Public Class OpenECry Public Shared OECClient1 As New OECClient() Public Event OnLoginFailed() Public Delegate Sub OEC_OnLoginFailedEvent(ByVal FailReason As OEC.Data.FailReason) Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click If txbUsername.Text = Nothing Or txbPassword.Text = Nothing Or txbServer.Text = Nothing Then 'Connect to the server, if the details are wrong then show the error message in the label. MsgBox("One of your required fields are empty, Please try again.", MsgBoxStyle.Critical, "Application Error") Else 'Catch Exception ' Try OECClient1.Disconnect() OECClient1.Connect(txbServer.Text, txbPort.Text, txbUsername.Text, txbPassword.Text, False) Catch ex As Exception MessageBox.Show(ex.Message) End Try End If End Sub End Class </code></pre> <p>I would really appreciate if someone who has more experience could help me out on this one. All I need is one example so I can do all the other events myself.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload