Feed Examples

This topic illustrates different ways to format your real-time data to serve any control or service that is real-time enabled.


Top of page

Example: Basic HTML Using iWay Server Page (iSP) Contexts
  1. Create an HTML file with the following content. Save the file in the iWay home directory as index.html.
    <html>
         <body>
              
              Total count of all enable service invocations =
              <% _ecount(enable.calls) %>
              <br/>
              Random <% _random(100) %>
              <br/>
              _IF(yes or _IF(true,_IF(true),_IF(no)) and 0) = 
                      <% _IF(yes or _IF(true,_IF(true),_IF(no)) and 0) %>
         </body>
    </html>
  2. Create a feed in any register set with a corresponding service.
  3. Enter a feed whose value is the following iWay Functional Language (iFL) expression:
    asis:_resource(_sreg(iway.home)index.html)

    Notice the prefix in the preceding code:

    asis:

    When constructing a feed, you must add that prefix to preserve the string that is returned.

  4. Reinitialize the corresponding service. Access the Feeds tab, and double-click the name of the feed that you entered in the register set.

    The output will be similar to the following.

    Total count of all enable service invocations = 181
    Random 41
    _IF(yes or _IF(true,_IF(true),_IF(no)) and 0) = false

Top of page

Example: Basic Really Simple Syndication (RSS)
  1. Create an XML file with the following content. Save the file in the iWay home directory as index.rss.
    <?xml version="1.0" ?>
    <rss version="2.0">
    <channel>
         <title>Enable Feeds powered by iSM <%=iwayversion%></title>
         <description>This RSS feed lists the feeds in Enable
         available for subscription.</description>
         <link><%=host-context %>/ism/enable-dat?configuration=<%=iwayconfig%></link>
         <item>
              <title>enable-calls Feed</title>
              <description>A feed which returns the total count of all invocations of
                        enable services. Current count: <% _ecount(enable.calls) %>
              </description>
              <link><%=host-context %>/ism/enable-dat?regs=enable-calls</link>
         </item>
         <item>
              <title>value Feed</title>
              <description>Current random value is <% _random(100) %></description>
              <link><%=host-context %>/ism/enable-dat?regs=value</link>
         </item>
    </channel>
    </rss>
  2. Create a feed in any register set with a corresponding service.
  3. Enter a feed whose value is the following iWay Functional Language (iFL) expression:
    asis:_resource(_sreg(iway.home)index.rss)

    Notice the prefix in the preceding code:

    asis:

    When constructing a feed, you must add that prefix to preserve the string that is returned.

  4. Reinitialize the corresponding service. Access the Feeds tab, and double-click the name of the feed that you entered in the register set.

    The browser will ask if you want to subscribe to the feed. If you choose to subscribe, you will see the feed that you created in the list of subscribed feeds in the browser.


Top of page

Example: Basic JavaScript Object Notation (JSON)

You can deserialize the following code using eval() in your JavaScript.

{
"iwayversion"="<%=iwayversion%>",
"hostcontext"="<%=host-context %>",
"enablecalls"="<% _ecount(enable.calls) %>"
}

Top of page

Example: JSON With Callback

You can pass the following code to eval() to call a local function named callback. The function callback passes the serialized value of the JSON object.

callback({
     "iwayversion"="<%=iwayversion%>",
     "hostcontext"="<%=host-context %>",
     "enablecalls"="<% _ecount(enable.calls) %>"
   }
)

Top of page

Example: JavaScript Web Application Programming Interface (API)

You can create your own Web API and import the JavaScript file into an HTML page.

Formatting the feed is as simple as populating a template of your feed with iWay Server Page (iSP) contexts that contain iWay Functional Language (iFL) functions.

var myenable =
{
     "iwayversion"="<%=iwayversion%>",
     "hostcontext"="<%=host-context %>",
     "enablecalls"="<% _ecount(enable.calls) %>"
} 
function getMyEnableInfo()
{ 
     return myenable;
}

iWay Software