Async responses to requests

16 views
Skip to first unread message

Steven J. Ackerman

unread,
Oct 21, 2014, 1:47:12 PM10/21/14
to Robert Quattlebaum, SMCP Developers Group Group

Robert-

 

How do I handle generating an asynchronous response for a request ?

 

I’m trying to connect SMCP to a scripting language running in another task. An inbound message will get routed to the node request handler via uip_newdata( ) which will queue parameters for the scripting language to process then signal the script an inbound request is available, then smcp_start_async_response( ) to return the empty response ? 

 

Then later when the script has processed the event and queued the parameters to generate its response the uip_poll( ) would deque the response parameters and smcp_outbound_begin_async_response( ) followed by adding the outbound results then outbound send ?

 

Looking at smcp_observable it seems like I will require a structure to relate the smcp_async_response with a smcp_transaction to make this work…

 

Can you please elaborate or direct me to some additional code to help me understand how to approach this ?

 

Thank you,

 

Steven J. Ackerman

Sarasota, FL

Blog: http://acslabs.wordpress.com

mailto:sjack...@verizon.net

 

Robert Quattlebaum

unread,
Oct 21, 2014, 5:15:55 PM10/21/14
to Steven J. Ackerman, SMCP Developers Group Group
Hi Steven,

When you get a request that you want to send an asynchronous response to, you use smcp_start_async_response to fill out a "struct smcp_async_response_s" structure. 

When you are ready to send your asynchronous response, you create a new transaction. From the "resend" callback of the transaction, you would call "smcp_outbound_begin_async_response()"  instead of the typical "smcp_outbound_begin_response()" that you would call directly from the inbound handler. From the "response" callback of the transaction, you would call "smcp_finish_async_response()" on the "struct smcp_async_response_s" structure to clean up. (It doesn't do anything at the moment, but it will do something in the future when I get finished adding session support)

That's it.

An example of this is in the plug test server source code: https://github.com/darconeous/smcp/blob/master/src/plugtest/plugtest-server.c#L109

-- Robert

Steven J. Ackerman

unread,
Oct 21, 2014, 5:33:57 PM10/21/14
to Robert Quattlebaum, SMCP Developers Group Group

Robert-

 

OK – I understand.

 

Thank you !

 

 

Reply all
Reply to author
Forward
0 new messages