Atozed Forums
Content handlers - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: Content handlers (/thread-945.html)

Pages: 1 2


Content handlers - lfeliz - 02-17-2019

Hi. 

Does a content handler run in its own thread?  I need to implement  a way to call into my app and get some information, content handler seems to be easiest way to do it.  I will move forward assuming it is for now.


RE: Content handlers - DanBarclay - 02-17-2019

There is a demo for Custom Content Handler. Yes, like each call to a session, the content handler call starts with its own thread.

In fact, it's easy to think of it as the first (and only) call to a new session. Like a "one call session". I don't know if Alex/Chad like that mental model but it helps me understand what I can and can't do. If you check the session list during the handler call you'll see your content handler listed. Not to worry, it's not a heavyweight (no forms or anything) but it's there. It disappears when the call is over (unlike a real session that hangs around a while before it's deleted).

Play with it. Very handy. I even have one set up that gives me a status on active sessions, and statistics on cumulative sessions and such.

Dan


RE: Content handlers - lfeliz - 02-17-2019

Excellent. Thank you! I am trying to implement a webhook for a payment system and thought this would be the best way to do it. I currently use one for my AWS Load balancer health check (it just a simple return), but your using it to provide status or statistics is cool. I need to look at some code I have in another project where I list out the active session and who is logged in. I need to incorporate someting like this in my AWS LB healthcheck to have it examine instance statistics as part to possibly take an instance offline when no users have been on it for a while.

- Lou


RE: Content handlers - lfeliz - 02-17-2019

How do I get the content sent via a Post to my Intraweb URL? I can get the query string etc.. Its a webhook sending me a JSON record in the body.


RE: Content handlers - Jose Nilton Pace - 02-17-2019

Lou, see this demo.


RE: Content handlers - DanBarclay - 02-17-2019

Also see the CustomContentHandlers demo.

You set up the Post URL when the handler is registered. The handler responds when the url (extension to your Intraweb URL) is sent. Accept the inbound data, send a response. As in the demo.

Various call parameters are available, pretty much as would be in a session call, but I think the inbound/outbound strings shown in the demo will give you what you want. Tinker with it a while and you'll learn a lot more.

Of course this is a straight up call. If you want some security on it you'll need to weed out calls you don't want to respond to.

Dan


RE: Content handlers - lfeliz - 02-19-2019

Thanks for reply. I took look at demo and then tested content handler using Chrome plugin Advanced Rest client to sent Post data to URL. I am ot able to get the body of the post. I can see that in raw headers the content length matches what in body, but no file, no content. Not sure where I go from here to grab the data that is sent via POST.

Cheers!


RE: Content handlers - DanBarclay - 02-19-2019

Request info is in the aRequest parameter.  First thing to check is to assure the Execute event is firing.  You didn't say specifically but I assume you were looking at the header from within the event.  If not, make sure the handler name is correct in your post.

The data for the PostDataDemo Jose linked should be in the file (read into xml stream in the Execute event).

The data for a Get (in the CustomContentHandlers demo) will be in aRequest.mQuery (and parsed as params if appropriate).

I suggest playing with both, maybe starting with the Get (CustomContentHandlers) if your event is not firing just because it's easier to watch how things are working with the more simple example.

Dan


RE: Content handlers - lfeliz - 02-19-2019

Yes..... thanks for replying. My event handler is firing and that is where I am checking the arequest parameter. I am currently trying to have it echo back what it gets, but no luck. I am using it for a webhook from chargebee which sends a JSON record. I am simulating it with a Chrome plugin that can submit a post request that sends the JSON in the Body so I can use a local debug break point to make sure it shitting the right lines of codes . I can see via raw header the content length is correct (2980) and content type is JSON. Filecount returns 0, hascontent is true and contentfields count is zero. Anway, I think I am going to focus on working with JSON unit to parse the JSON data received so I can act on it. My plan was to log all webhook events to table and have a process take care of items on a regular interval - every minute, 5 min, 10 min etc....

I tried the PostData demo using the chrome plugin and doing a form post submit xml in body to URL and all I get back is a 404 error. I appreciate you taking time to look at this. cheers!


RE: Content handlers - lfeliz - 02-20-2019

I have decided to implement the Webhook handler the payment service in PHP for now as all I was trying to do was receive the information (Body) and place in a queue for processing.

Cheers!