question

Upvotes
Accepted
61 2 4 9

Determine Connection State in REDI

In general the documentation and sample code provided only make passing reference to the RediLib.Application object and it's use. Were it not for the sample code there's not enough documentation on creating a Redi connection. Based on this I'm left in the dark a bit on how I am to determine if my connection to Redi Plus is active.

There are a few callbacks within the RediLib.Application object that don’t seem to ever be called. Namely Connected and Disconnected. None of the demo code seemed to make any use of them and I was wondering if they were deprecated or just called infrequently. I've tried turning off the RediPlus app while connected to see if it would create a disconnect event and it did not. This lead me wondering how will I know if I’m connected to REDI? Sure there’s a few callbacks when I connect giving me msg 14 stuff. But if the RediPlus App dies or the connection drops is there any way for my code to know about it?

I'm attempted to call the method IsApplicationReady every few minutes but it throws an exception.

The API documentation doesn't talk about it and the sample code doesn’t seem to cover it either.

Thanks,

apiredi-apiconnection
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
136 1 2 3

This is one way to do it.

public MainWindow() {

redi = new RediLib.Application();

redi.ApplicationClosed += Redi_ApplicationClosed;

InitializeComponent();

Side.Items.Add("Buy");

Side.Items.Add("Sell");

}

private void Redi_ApplicationClosed() {

Console.WriteLine("Application Closed");

return;

}

I tested this and I see "Application Closed" in Visual Sudio console when I close the R+ application while the API application is running.

Calling isApplicationReady ahead of logging into R+ leads to a few problems. The first being you will initialize and call RediLib objects/methods, which assumes R+ connection. This leads us to a fundamental assumption about API applications, which is that we assume R+ is up and running ahead of running the API applcation.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea