Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about COM integration of HTTP server
#1
Hi -

I wanted to integrate a small HTTP server into a QuickMacros application and I wanted to see if I was going to run into a problem too big to solve.

(The basic idea is to enable inter-machine access to applications using QuickMacros as a bridge; HTTP is pretty much supported everywhere).

What I was planning to do was:
  • Use an existing embedded HTTP server engine like Nancyhttps://github.com/NancyFx/Nancy#readme. This way I don't have to re-implement the HTTP server state machines, authentication, and a bunch of other things.
  • I would wrap this in a COM object that I would instantiate from QuickMacros.
  • When a URL was handled by the Nancy engine - I'd generate a COM event and handle this in a macro.

I believe that the main programming issue would be how threading was handled. The events need to be handled in the same thread as the one where the COM object was instantiated: when a HTTP request comes in in C# I'll have to put the event into the thread that QM is expecting and then wait for the response from QM to return the data to the caller.

All of this seems doable although I'm sure I'll make plenty of mistakes. Is there anything that I'm missing that I should know about?

Thanks

Sean
#2
I don't have much experience in this. I think everything here is correct.

It's easy to switch to other thread with SendMessage or PostMessage. COM object's thread creates a hidden message-only window, and HTTP server's thread sends messages to it.

Don't forget that QM macro must process messages. If it is a dialog or other window, or has a message loop, it already processes messages. Else need opt waitmsg 1 and wait().

Or HTTP server's thread could call a QM function as a callback function in its thread. Then don't need events. And QM macro does not have to process messages.
#3
Quote:Or HTTP server's thread could call a QM function as a callback function in its thread. Then don't need events. And QM macro does not have to process messages.

How do I do this? Do I just define a method in my COM object that accepts a function pointer and then pass a QM function to it for the callback? Or is there some registration process in QM to expose the function to the COM object?

Thanks!
#4
Yes, simply. No registration needed.

comObj.FunctionX(&QmFunction)


Forum Jump:


Users browsing this thread: 1 Guest(s)