Page 1 of 1

Send message to JS?

PostPosted: Mon Apr 27, 2020 7:40 am
by ChrisKennedy
Hi -

We have a web page (TAPortal) that we need to load into a browser, then have C# code send messages to, and receive messages from, TAPortal. I have the CefGlue demo application running and loading TAPortal into a browser. I've also successfully registered to receive messages from JS (using the code in Wrapper.MessageRouter that is marked as obsolete). TAPortal posts a message when it is finished loading ('taportal_initialized'), and I am receiving that message.

I cannot figure out how to send a message to TAPortal. The message I need to send is a JSON string. Once TAPortal has processed that message, it will post a response message.

I have been able to get the message to TAPortal by setting a breakpoint in DemoApp.DemoMessageRouterHandler.OnQuery. When the breakpoint gets hit when it receives the 'taportal_initialized' message, I manually call callback.Success, passing in the JSON string. TAPortal receives that message and processes it, and then OnQuery gets called again, this time with the response to my message.

I've looked at the DemoApp.SendProcessMessageCommand code, but I'm not sure where that message is supposed to go.

In order to get this far, I had to pull in the code in Wrapper.MessageRouter that was marked as obsolete. So, I guess really what I should be asking is, how do I send and receive messages from JS using the latest code?

Re: Send message to JS?

PostPosted: Mon Apr 27, 2020 11:59 am
by ChrisKennedy
And, just that quickly, we figured out what we were doing wrong.

I didn't need to send the message manually, when I register 'cefRegisterHandler', it's sending me a callback that I should call, that is how I get the message to TaPortal.

So, please ignore.