Example: web_util_set_formatted_request_body

In this example, web_util_set_formatted_request_body sets the request body to a new, formatted value. The target number is incremented each time the callback is invoked and the request XML is changed to include the new target number.

The callbacks are registered in Action.c. web_util_set_formatted_request_body is invoked in Poll_0_RequestCB.

From Action.c:

    web_reg_async_attributes("ID=LongPoll_1",
        "Pattern=LongPoll",
        "URL=http://myserver:2080/a_poll",
        "RequestCB=LongPoll_1_RequestCB",
        "ResponseCB=LongPoll_1_ResponseCB",
        LAST);

The implementation of the request callback in AsyncCallbacks.c:

int LongPoll_1_RequestCB()
{
    web_util_set_formatted_request_body("<AMFPacket AMF_version=\"3\">"
      "<AMFHeaders />"
      "<Messages>"
        "<Message method=\"null\" target=\"/{Target_LongPoll_1}\">"
          "<Arguments>"
            "<Argument>"
              "<AMF3>"
                "<object-externalizable-custom>"
                  "<flex.messaging.messages.CommandMessage>"
                    "<destination></destination>"
                    "<messageId>76D12BD6-7DAC-FAF7-06F0-D178275E624A</messageId>"
                    "<timestamp>0</timestamp>"
                    "<timeToLive>0</timeToLive>"
                    "<headers>"
                      "<entry>"
                        "<string>DSMessagingVersion</string>"
                        "<int>1</int>"
                      "</entry>"
                      "<entry>"
                        "<string>DSId</string>"
                        "<string>nil</string>"
                      "</entry>"
                    "</headers>"
                    "<body class=\"flex.messaging.io.amf.ASObject\" serialization=\"custom\">"
                      "<unserializable-parents />"
                      "<map>"
                        "<default>"
                          "<loadFactor>0.75</loadFactor>"
                          "<threshold>12</threshold>"
                        "</default>"
                        "<int>16</int>"
                        "<int>0</int>"
                      "</map>"
                      "<flex.messaging.io.amf.ASObject>"
                        "<default>"
                          "<inHashCode>false</inHashCode>"
                          "<inToString>false</inToString>"
                        "</default>"
                      "</flex.messaging.io.amf.ASObject>"
                    "</body>"
                    "<correlationId></correlationId>"
                    "<operation>5</operation>"
                  "</flex.messaging.messages.CommandMessage>"
                "</object-externalizable-custom>"
              "</AMF3>"
            "</Argument>"
          "</Arguments>"
        "</Message>"
      "</Messages>"
    "</AMFPacket>");*/

    return WEB_ASYNC_CB_RC_OK;
}