Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Content handlers
#1
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.
Reply
#2
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
Reply
#3
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
Reply
#4
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.
Reply
#5
Lou, see this demo.
Reply
#6
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
Reply
#7
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!
Reply
#8
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
Reply
#9
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!
Reply
#10
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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)