Thursday, December 27, 2012

The New WinRT SDK and Demo

With the introduction of Windows 8, a new application architecture, namely Windows Runtime or WinRT, was also introduced.

WinRT, which has to be used for an application to be published on the Windows Store, is not fully compatible with the old .NET framework. But don't worry, we've got you covered again: with the release of Lightstreamer 5.1 we have made available a brand new WinRT client SDK that can be used to develop Lightstreamer-enabled Windows Store apps.


As we are used to, we also show you how to leverage the new SDK with a simple Stock-List Demo application: you can install it from the store on your Windows 8 or Windows RT PC or tablet from this Windows Store page. (note: the install button does not work/appear on chrome).

Once installed the demo application will appear in your start menu. Click on the tile to launch the application




While the application is running, the live tile can be updated with new values from the "Ations Europe" stock

The full source code of the demo is available in the examples folder of the new SDK. Let's check it out.

The demo, which is a port of the Lightstreamer Windows Phone Stock-List demo, is made of three main source files:

App.xaml.cs is the main application file. It contains application event handling code (application launching, closed, activated, etc), Lightstreamer Client streaming controls (start, stop) and part of the auto-reconnection logic required when the connection quality is weak. It makea use of the Windows.Storage.ApplicationDataContainer API to store the current status of the start/stop button of the application.

MainPage.xaml.cs is the only page of the application. It handles the simple table and the live tile containing real-time stock quotes, which are kept up to date by implementing  the custom ILightstreamerListener interface.

Several lines in this file are dedicated to the animation code used for highlighting cells using the UpdateCell class; on the other hand the handling of the live tile is in a proof of concept status as its life cycle was not taken much into account. Both the grid and live tile updates are handled by the OnItemUpdate method relying on the previously mentioned UpdateCell.
As the custom interface also offers the connection status, an image (and label) is kept synced with the current status of the connection through the OnStatusChange method.
The page also handles the Start/Stop button calls that are forwarded to the App class (from the App.xaml.cs file) and  its "Charms Bar" that only contains a privacy policy link.

LightstreamerClient is a simple wrapper for LSClient public class (see Lightstreamer WinRT Client API) and uses two listeners:  StocklistConnectionListener and StocklistHandyTableListener,  respectively implementing a Connection Status listener (IConnectionListener)  and a Real-Time Data Updates listener (IHandyTableListener). These classes simply forward all the events to a ILightstreamerListener, that in this case is our MainPage class from the MainPage.xaml.cs file.

Enjoy the new SDK and feel free to ask any question or report any issue on the dedicated forum.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.