Skip to content

Commit 7d46d94

Browse files
committed
Upgrade to Client lib 5 (Unified)
1 parent 41e0eec commit 7d46d94

6 files changed

Lines changed: 272 additions & 195 deletions

File tree

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!-- START DESCRIPTION lightstreamer-example-stocklist-client-javascript-basic-stock-list-demo---electron-client -->
44

5-
This project contains a demo application showing the integration between the [Lightstreamer .Net Standard Client](https://www.lightstreamer.com/api/ls-dotnetstandard-client/latest/) library and [Xamarin](https://docs.microsoft.com/it-it/xamarin/) cross-platform mobile application development tool.
5+
This project contains a demo application showing the integration between the [Lightstreamer .Net Standard Client](https://lightstreamer.com/temp/temp_dotnet_unified_docs/) library and [Xamarin](https://docs.microsoft.com/it-it/xamarin/) cross-platform mobile application development tool.
66

77
![Demo ScreenShot](screen_large.png)<br>
88

@@ -21,8 +21,8 @@ This project shows how is it possible to integrate the <b>.Net Standard Client A
2121
* `AboutPage.xaml` and (`AboutPage.xaml.cs`) is tha About page and contains a brief intoduction to the demo.
2222
* `RTFeed.cs` class acts as a bridge between the pages and the Lightstreamer Client library, in order to subscribe the necessary Items and collect all updates in real time. Indeed this class is used as BindingContext for the viusal Xamarin widgets.
2323
This class also takes care of opening and closing the connection to the Lightstreamer server.
24-
* `TestConnectionListener.cs` this class implements the <i>IConnectionListener</i> interface of Lightstreamer Client API, and receives all the information about changes in the status of the connection with the Lightstreamer server.
25-
* `QuoteListener.cs` and `DetailsListener.cs` implement the <i>IHandyTableListener</i> interface of Lightstreamer Client API, and receives the reale time updates for the Items subscribed.
24+
* `TestConnectionListener.cs` this class implements the [ClientListener](https://lightstreamer.com/temp/temp_dotnet_unified_docs/api/com.lightstreamer.client.ClientListener.html) interface of Lightstreamer Client API, and receives all the information about changes in the status of the connection with the Lightstreamer server.
25+
* `QuoteListener.cs` and `DetailsListener.cs` implement the [SubscriptionListener](https://lightstreamer.com/temp/temp_dotnet_unified_docs/api/com.lightstreamer.client.SubscriptionListener.html) interface of Lightstreamer Client API, and receives the reale time updates for the Items subscribed.
2626

2727

2828
Check out the sources for further explanations.<br>
@@ -38,7 +38,7 @@ To build your own version of the demo follow these steps:
3838
* You can choose the target devices between iOs, Androin and UWP.
3939
* You should complete this project with the <b>Lightstreamer .NET Standard Client</b> library, to be used for the build process, trough NuGet. Follow these steps:
4040
* In the "Solution Explorer" tab, right click on the project and choose `Manage NuGet Packages ...`
41-
* In the Search text box enter `Lightstreamer`
41+
* In the Search text box enter `Lightstreamer` and be sure to flag the *Include preliminary version* check-box
4242
* Choose Lightstreamer.DotNetStandard.Client then click `Install` and then `Ok`
4343
* You may run the demo against your local server or using our online server `push.lightstreamer.com`. The server to which the demo will connect to is configured in the `RTfeed.cs` file; by default the demo targets our demo server at https://push.lightstreamer.com.<br>
4444
* In the former case, note that, as prerequisite, the [Lightstreamer - Stock- List Demo - Java Adapter](https://github.com/Lightstreamer/Lightstreamer-example-Stocklist-adapter-java) has to be deployed on your local Lightstreamer Server instance. Please check out that project and follow the installation instructions provided with it.
@@ -64,6 +64,7 @@ To build your own version of the demo follow these steps:
6464

6565
## Lightstreamer Compatibility Notes
6666

67-
* Compatible with Lightstreamer .NET Standard Client Library version 4.0.0 or newer.
68-
* Fnsure that .Net Standard Client API is supported by Lightstreamer Server license configuration.
67+
* Compatible with Lightstreamer .NET Standard Client Library version 5.0.0 or newer.
68+
* Ensure that .Net Standard Client API is supported by Lightstreamer Server license configuration.
69+
* For instructions compatible with .NET Standard Client library version 4.x, please refer to [this tag](https://github.com/Lightstreamer/Lightstreamer-example-StockList-client-Xamarin/tree/for_client_4.x).
6970

XDemo5/DetailsListener.cs

Lines changed: 69 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,102 +16,139 @@
1616
*/
1717
#endregion License
1818

19-
using Lightstreamer.DotNetStandard.Client;
19+
using com.lightstreamer.client;
2020
using System.Diagnostics;
2121
using Xamarin.Forms;
2222

2323
namespace XDemo5
2424
{
25-
internal class DetailsListener : IHandyTableListener
25+
internal class DetailsListener : SubscriptionListener
2626
{
2727
private RTfeed rTfeed;
2828

2929
public DetailsListener(RTfeed rTfeed)
3030
{
3131
this.rTfeed = rTfeed;
3232
}
33-
private string NotifyUpdate(IUpdateInfo update)
33+
34+
private string NotifyUpdate(ItemUpdate update)
3435
{
3536
return update.Snapshot ? "snapshot" : "update";
3637
}
3738

38-
public void OnUpdate(int itemPos, string itemName, IUpdateInfo update)
39+
// ---
40+
41+
void SubscriptionListener.onClearSnapshot(string itemName, int itemPos)
42+
{
43+
Debug.WriteLine("Clear snapshot evernt received for " + itemName);
44+
}
45+
46+
void SubscriptionListener.onCommandSecondLevelItemLostUpdates(int lostUpdates, string key)
47+
{
48+
throw new System.NotImplementedException();
49+
}
50+
51+
void SubscriptionListener.onCommandSecondLevelSubscriptionError(int code, string message, string key)
52+
{
53+
throw new System.NotImplementedException();
54+
}
55+
56+
void SubscriptionListener.onEndOfSnapshot(string itemName, int itemPos)
3957
{
58+
Debug.WriteLine("End of snapshot received for " + itemName);
59+
}
4060

61+
void SubscriptionListener.onItemLostUpdates(string itemName, int itemPos, int lostUpdates)
62+
{
63+
Debug.WriteLine("Lost " + lostUpdates + " updates for " + itemName);
64+
}
65+
66+
void SubscriptionListener.onItemUpdate(ItemUpdate update)
67+
{
4168
Debug.WriteLine("Details received.");
4269

4370
Debug.WriteLine(NotifyUpdate(update) +
44-
" for " + itemPos + ":" + update.GetNewValue(1) + " - " + update.GetNewValue(3)
71+
" for " + update.ItemName + ":" + update.getValue(1) + " - " + update.getValue(3)
4572
);
46-
4773

48-
if (update.IsValueChanged(1))
74+
75+
if (update.isValueChanged(1))
4976
{
50-
rTfeed.DetailsName = update.GetNewValue(1);
77+
rTfeed.DetailsName = update.getValue(1);
5178
}
5279

53-
if (update.IsValueChanged(2))
80+
if (update.isValueChanged(2))
5481
{
55-
rTfeed.DetailsLast = update.GetNewValue(2);
82+
rTfeed.DetailsLast = update.getValue(2);
5683
}
5784

58-
if (update.IsValueChanged(3))
85+
if (update.isValueChanged(3))
5986
{
60-
rTfeed.DetailsTime = update.GetNewValue(3);
87+
rTfeed.DetailsTime = update.getValue(3);
6188
}
6289

63-
if (update.IsValueChanged(4))
90+
if (update.isValueChanged(4))
6491
{
65-
rTfeed.DetailsMin = update.GetNewValue(4);
92+
rTfeed.DetailsMin = update.getValue(4);
6693
}
6794

68-
if (update.IsValueChanged(5))
95+
if (update.isValueChanged(5))
6996
{
70-
rTfeed.DetailsMax = update.GetNewValue(5);
97+
rTfeed.DetailsMax = update.getValue(5);
7198
}
7299

73-
if (update.IsValueChanged(6))
100+
if (update.isValueChanged(6))
74101
{
75-
rTfeed.DetailsChg = update.GetNewValue(6);
76-
if (float.Parse(update.GetNewValue(6)) > 0)
102+
rTfeed.DetailsChg = update.getValue(6);
103+
if (float.Parse(update.getValue(6)) > 0)
77104
{
78105
rTfeed.DetailsChgDiff = Color.Green;
79-
} else
106+
}
107+
else
80108
{
81109
rTfeed.DetailsChgDiff = Color.Red;
82110
}
83111
}
84112

85-
if (update.IsValueChanged(7))
113+
if (update.isValueChanged(7))
86114
{
87-
rTfeed.DetailsBid = update.GetNewValue(7);
115+
rTfeed.DetailsBid = update.getValue(7);
88116
}
89117

90-
if (update.IsValueChanged(8))
118+
if (update.isValueChanged(8))
91119
{
92-
rTfeed.DetailsAsk = update.GetNewValue(8);
120+
rTfeed.DetailsAsk = update.getValue(8);
93121
}
122+
}
94123

124+
void SubscriptionListener.onListenEnd(Subscription subscription)
125+
{
126+
// ...
127+
}
128+
129+
void SubscriptionListener.onListenStart(Subscription subscription)
130+
{
131+
// ...
95132
}
96133

97-
public void OnSnapshotEnd(int itemPos, string itemName)
134+
void SubscriptionListener.onSubscription()
98135
{
99-
Debug.WriteLine("end of snapshot for " + itemPos);
136+
Debug.WriteLine("Subscription");
100137
}
101138

102-
public void OnRawUpdatesLost(int itemPos, string itemName, int lostUpdates)
139+
void SubscriptionListener.onSubscriptionError(int code, string message)
103140
{
104-
Debug.WriteLine(lostUpdates + " updates lost for " + itemPos);
141+
Debug.WriteLine("Subscription Error: " + message + " (" + code +").");
105142
}
106143

107-
public void OnUnsubscr(int itemPos, string itemName)
144+
void SubscriptionListener.onUnsubscription()
108145
{
109-
Debug.WriteLine("unsubscr " + itemPos);
146+
Debug.WriteLine("Unsubscription");
110147
}
111148

112-
public void OnUnsubscrAll()
149+
void SubscriptionListener.onRealMaxFrequency(string frequency)
113150
{
114-
Debug.WriteLine("unsubscr table");
151+
Debug.WriteLine("Real Max Frequency: " + frequency);
115152
}
116153
}
117154
}

0 commit comments

Comments
 (0)