Would you have a few minutes to suggest the best Chilkat control for what I'm doing? Right now I'm using the HTTP control, primarily because of the async methods that it has. I'm mostly sending JSON to and from my main server.
I have a connection which is used for HTTP long polling. It connects to the server and basically says "here's my site id and password. I'm going to wait for you to send me something..." It holds the connection open for 45 minutes and if it receives nothing, it closes itself and re-connects. If it does receive a response from the server, it processes the response, drops the connection and reconnects. My question here is, would the REST control be a better fit than the HTTP control?
The other connections are just basic HTTP POSTs or GETs and the standard HTTP control seems to work fine for these.
Lastly, I haven't been able to wire up the ActiveX events interface with any success yet for HTTP control. Not sure what I'm missing... Right now i have a timer that checks for the status of "Finished = 1" and then acts on it, which works, bound an event bound model would be better. I have the interface implemented in my VFP code and it's bound using VFP's EVENTHANDLER, but none of the events actually fire. Also, I wasn't clear from the documentation, which object the events were to be bound to, is it the task object or the http one?
These are good questions, and I'll give you my thoughts in no particular order..
Don't use the old and deprecated async mehods in HTTP. These are the methods having names that begin with the word "Async".
Any Chilkat method that communicates over a network, or can possibly consume a lot of processing time (such as Zip compression) will have the standard event callbacks (AbortCheck, PercentDone, ProgressInfo, etc. PercentDone only occurs where it is possible to know a percentage of completion.) Also, each of these methods automatically has a corresponding async method, which has the same name but ends with "Async". Each of these methods returns a Chilkat Task object. If you're going to use an async method, these are the ones to use. Also, because all methods having event callbacks have a corresponding async method, HTTP has no advantage over REST because both have full async capability.
The REST API has the advantage in that it's possible to separate the "connect", the "send request", and the "receive response" in separate method calls. This means each can have its own event callbacks, and for the case of progress monitoring, you can monitor the progress of the send in one API call, and then monitor the progress of the receive in another API call. (Assuming it makes sense to monitor percent completion. For example, it is impossible to get a percent completion if the HTTP response is chunked because there is no way to know how much response data is forthcoming.)
With HTTP, a given method call does both SEND and RECEIVE. (It potentially also makes the connection if necessary.) Let's say you do a POST with the HTTP API and want to monitor percent completion. A choice has to be made: Does the sending of the request get monitored, or the receiving of the response? For HTTP uploads, it makes sense to monitor percent completion for the send side. For most everything else, the receive side makes sense. Chilkat chooses which based on the size of the HTTP request (or the type of HTTP request, such as multipart/form-data).
I know the ActiveX events are working. There is a Foxpro .prg file you can download here: http://chilkatdownload.com/chilkat_foxpro_prg.zip Compare this with your code.
Also with events, check to make sure the ProgressInfo events are working. Maybe PercentDone is not possible based on the situation.
Also regarding events: An event callback from a background (async) task will be in a background thread. It's not in the main UI thread of your program. For older environments, which likely never thought of such things occurring when designed, such as VB6 or FoxPro, I'm not sure if trying to field event callbacks from a background thread is a good idea. (You'd be playing with fire in my opinion..)
Those are my thoughts for now.. hope it helps.
Yes, I am using the methods that end with Async. PostJsonAsync specifically.
Thanks for the clarification on using REST vs. HTTP.
I've used EventHandler before to work with other COM events, but I can't say that I've used it in conjunction with a COM object that runs in background thread. VFP returns true for the EventHandler line binding properly, but none of the events actually fire. I made sure that the system setting for AutoYield was on as well. No luck. Based on your last statement, a VFP timer, polling for results may actually be the only way to do what I need to do.