Skip to content

Commit

Permalink
Version 1.1.0: Performance improvements and breaking API changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgnsm committed Jan 2, 2019
1 parent 1117428 commit b802389
Show file tree
Hide file tree
Showing 25 changed files with 953 additions and 160 deletions.
4 changes: 2 additions & 2 deletions Build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ variables:
buildPlatform: 'any cpu'
buildConfiguration: 'release'
major: 1
minor: 0
patch: $[counter('v102', 2)]
minor: 1
patch: $[counter('v110', 0)]

steps:
- task: NuGetCommand@2
Expand Down
14 changes: 12 additions & 2 deletions Millistream.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Millistream.Streaming.Integ
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{C04FDBC8-EB8C-4D9F-8F3A-B6A2DA42566D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp", "Samples\ConsoleApp\ConsoleApp.csproj", "{04B84E2C-DAFD-4E8B-84A8-0BF3CC7512EE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp", "Samples\v1.0.0\ConsoleApp\ConsoleApp.csproj", "{04B84E2C-DAFD-4E8B-84A8-0BF3CC7512EE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{41167C76-5F76-4049-B890-1A9D4E24BDE5}"
ProjectSection(SolutionItems) = preProject
Build\azure-pipelines.yml = Build\azure-pipelines.yml
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp", "Samples\ConsoleApp\ConsoleApp.csproj", "{78D0CB1A-31D5-44AD-8D93-76DA8136604B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "v1.0.0", "v1.0.0", "{250E61F3-D935-4729-8F60-9E7C2E6A6F40}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -45,6 +49,10 @@ Global
{04B84E2C-DAFD-4E8B-84A8-0BF3CC7512EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04B84E2C-DAFD-4E8B-84A8-0BF3CC7512EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04B84E2C-DAFD-4E8B-84A8-0BF3CC7512EE}.Release|Any CPU.Build.0 = Release|Any CPU
{78D0CB1A-31D5-44AD-8D93-76DA8136604B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78D0CB1A-31D5-44AD-8D93-76DA8136604B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78D0CB1A-31D5-44AD-8D93-76DA8136604B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78D0CB1A-31D5-44AD-8D93-76DA8136604B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -53,7 +61,9 @@ Global
{F5CC00D3-449B-4280-8A01-B649AAE9D2C8} = {660A05E5-718C-45D0-8705-14C9B5DF6F98}
{F86497BC-8BBD-4BD2-A050-FD0882DE69FF} = {A0152BDC-0D9F-4AE2-BF3E-CE24F85ECAF8}
{DB6A274F-DB2C-4581-88F9-4A798A9D3DF7} = {A0152BDC-0D9F-4AE2-BF3E-CE24F85ECAF8}
{04B84E2C-DAFD-4E8B-84A8-0BF3CC7512EE} = {C04FDBC8-EB8C-4D9F-8F3A-B6A2DA42566D}
{04B84E2C-DAFD-4E8B-84A8-0BF3CC7512EE} = {250E61F3-D935-4729-8F60-9E7C2E6A6F40}
{78D0CB1A-31D5-44AD-8D93-76DA8136604B} = {C04FDBC8-EB8C-4D9F-8F3A-B6A2DA42566D}
{250E61F3-D935-4729-8F60-9E7C2E6A6F40} = {C04FDBC8-EB8C-4D9F-8F3A-B6A2DA42566D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {13B18705-419F-4BCB-B456-5A1E4198605D}
Expand Down
61 changes: 42 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,58 @@ Once you have installed the native `libmdf` library on your computer, you can th
//1. Create an instance of the DataFeed class
using (DataFeed dataFeed = new DataFeed())
{
//2. Hook up event handlers to the ConnectionStatusChanged and DataReceived events.
//2. Hook up an event handler to the ConnectionStatusChanged event.
dataFeed.ConnectionStatusChanged += OnConnectionStatusChanged;
dataFeed.DataReceived += OnDataReceived;
//3. Call the Connect method to connect to the feed and authenticate
dataFeed.Connect(Host, Username, Password);
//4. Issue a subscription request and wait for the DataReceived event to get raised
dataFeed.Request(new SubscribeMessage(
RequestType.MDF_RT_FULL, // <- The type of request. Full (image+streaming) in this case.
new RequestClass[1] { RequestClass.MDF_RC_QUOTE }) //<- What kind of data to request. Quotes in this case.
//3. Subscribe to the Data observable
dataFeed.Data.Subscribe(new Observer(dataFeed));
//4. Call the Connect method to connect to the feed and authenticate
if (dataFeed.Connect(Host, Username, Password))
{
InstrumentReferences = new ulong[1] { 772 }, //<- What instrument identifier(s) the request is for. 772 is the unique identifier for Ericsson B on Nasdaq OMX Stockholm
});
//5. Issue a subscription request and wait for the DataReceived event to get raised
dataFeed.Request(new SubscribeMessage(
RequestType.MDF_RT_FULL, // <- The type of request. Full (image+streaming) in this case.
new RequestClass[1] { RequestClass.MDF_RC_QUOTE }) //<- What kind of data to request. Quotes in this case.
{
InstrumentReferences = new ulong[1] { 772 }, //<- What instrument identifier(s) the request is for. 772 is the unique identifier for Ericsson B on Nasdaq OMX Stockholm
});
}
else
{
Console.WriteLine("Failed to connect to the data feed.");
}

//prevent the app from terminating until you press a key
Console.ReadLine();
}
}

private static void OnDataReceived(object sender, DataReceivedEventArgs e)
static void OnConnectionStatusChanged(object sender,
ConnectionStatusChangedEventArgs e) =>
Console.WriteLine($"{DateTime.Now.ToShortTimeString()} - " +
$"Connection Status: {e.ConnectionStatus}");
}

class Observer : IObserver<ResponseMessage>
{
private readonly IDataFeed _dataFeed;

public Observer(IDataFeed dataFeed) => _dataFeed = dataFeed;

public void OnNext(ResponseMessage message)
{
Console.WriteLine($"{DateTime.Now.ToShortTimeString()} - " +
$"Received a {e.Message.MessageReference} message with the following fields:");
foreach (var field in e.Message.Fields)
Console.WriteLine($"{field.Key}: {field.Value}");
$"Received a {message.MessageReference} message with the following fields:");
foreach (var field in message.Fields)
#if NET_CORE
Console.WriteLine($"{field.Key}: {Encoding.UTF8.GetString(field.Value.Span)}");
#else
Console.WriteLine($"{field.Key}: {Encoding.UTF8.GetString(field.Value.ToArray())}");
#endif
_dataFeed?.Recycle(message);
}

private static void OnConnectionStatusChanged(object sender,
ConnectionStatusChangedEventArgs e) =>
Console.WriteLine($"{DateTime.Now.ToShortTimeString()} - " +
$"Connection Status: {e.ConnectionStatus}");
public void OnCompleted() { }

public void OnError(Exception exception) => Console.WriteLine(exception.Message);
}
}
}
4 changes: 4 additions & 0 deletions Samples/ConsoleApp/ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
<ProjectReference Include="..\..\Source\Millistream.Streaming\Millistream.Streaming.csproj" />
</ItemGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<DefineConstants>NET_CORE</DefineConstants>
</PropertyGroup>

</Project>
30 changes: 30 additions & 0 deletions Samples/ConsoleApp/Observer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Millistream.Streaming;
using System;
using System.Text;

namespace ConsoleApp
{
class Observer : IObserver<ResponseMessage>
{
private readonly IDataFeed _dataFeed;

public Observer(IDataFeed dataFeed) => _dataFeed = dataFeed;

public void OnNext(ResponseMessage message)
{
Console.WriteLine($"{DateTime.Now.ToShortTimeString()} - " +
$"Received a {message.MessageReference} message with the following fields:");
foreach (var field in message.Fields)
#if NET_CORE
Console.WriteLine($"{field.Key}: {Encoding.UTF8.GetString(field.Value.Span)}");
#else
Console.WriteLine($"{field.Key}: {Encoding.UTF8.GetString(field.Value.ToArray())}");
#endif
_dataFeed?.Recycle(message);
}

public void OnCompleted() { }

public void OnError(Exception exception) => Console.WriteLine(exception.Message);
}
}
37 changes: 18 additions & 19 deletions Samples/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,32 @@ static void Main(string[] args)
//1. Create an instance of the DataFeed class
using (DataFeed dataFeed = new DataFeed())
{
//2. Hook up event handlers to the ConnectionStatusChanged and DataReceived events.
//2. Hook up an event handler to the ConnectionStatusChanged event.
dataFeed.ConnectionStatusChanged += OnConnectionStatusChanged;
dataFeed.DataReceived += OnDataReceived;
//3. Call the Connect method to connect to the feed and authenticate
dataFeed.Connect(Host, Username, Password);
//4. Issue a subscription request and wait for the DataReceived event to get raised
dataFeed.Request(new SubscribeMessage(
RequestType.MDF_RT_FULL, // <- The type of request. Full (image+streaming) in this case.
new RequestClass[1] { RequestClass.MDF_RC_QUOTE }) //<- What kind of data to request. Quotes in this case.
//3. Subscribe to the Data observable
dataFeed.Data.Subscribe(new Observer(dataFeed));
//4. Call the Connect method to connect to the feed and authenticate
if (dataFeed.Connect(Host, Username, Password))
{
InstrumentReferences = new ulong[1] { 772 }, //<- What instrument identifier(s) the request is for. 772 is the unique identifier for Ericsson B on Nasdaq OMX Stockholm
});
//5. Issue a subscription request and wait for the DataReceived event to get raised
dataFeed.Request(new SubscribeMessage(
RequestType.MDF_RT_FULL, // <- The type of request. Full (image+streaming) in this case.
new RequestClass[1] { RequestClass.MDF_RC_QUOTE }) //<- What kind of data to request. Quotes in this case.
{
InstrumentReferences = new ulong[1] { 772 }, //<- What instrument identifier(s) the request is for. 772 is the unique identifier for Ericsson B on Nasdaq OMX Stockholm
});
}
else
{
Console.WriteLine("Failed to connect to the data feed.");
}

//prevent the app from terminating until you press a key
Console.ReadLine();
}
}

private static void OnDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine($"{DateTime.Now.ToShortTimeString()} - " +
$"Received a {e.Message.MessageReference} message with the following fields:");
foreach (var field in e.Message.Fields)
Console.WriteLine($"{field.Key}: {field.Value}");
}

private static void OnConnectionStatusChanged(object sender,
static void OnConnectionStatusChanged(object sender,
ConnectionStatusChangedEventArgs e) =>
Console.WriteLine($"{DateTime.Now.ToShortTimeString()} - " +
$"Connection Status: {e.ConnectionStatus}");
Expand Down
12 changes: 12 additions & 0 deletions Samples/v1.0.0/ConsoleApp/ConsoleApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net45;netcoreapp2.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Millistream.Streaming" Version="1.0.2" />
</ItemGroup>

</Project>
54 changes: 54 additions & 0 deletions Samples/v1.0.0/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using Millistream.Streaming;

namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
const string Host = "HOST";
const string Username = "YOUR_USERNAME";
const string Password = "YOUR_PASSWORD";

//1. Create an instance of the DataFeed class
using (DataFeed dataFeed = new DataFeed())
{
//2. Hook up event handlers to the ConnectionStatusChanged and DataReceived events.
dataFeed.ConnectionStatusChanged += OnConnectionStatusChanged;
dataFeed.DataReceived += OnDataReceived;
//3. Call the Connect method to connect to the feed and authenticate
if(dataFeed.Connect(Host, Username, Password))
{
//4. Issue a subscription request and wait for the DataReceived event to get raised
dataFeed.Request(new SubscribeMessage(
RequestType.MDF_RT_FULL, // <- The type of request. Full (image+streaming) in this case.
new RequestClass[1] { RequestClass.MDF_RC_QUOTE }) //<- What kind of data to request. Quotes in this case.
{
InstrumentReferences = new ulong[1] { 772 }, //<- What instrument identifier(s) the request is for. 772 is the unique identifier for Ericsson B on Nasdaq OMX Stockholm
});
}
else
{
Console.WriteLine("Failed to connect to the data feed.");
}

//prevent the app from terminating until you press a key
Console.ReadLine();
}
}

static void OnDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine($"{DateTime.Now.ToShortTimeString()} - " +
$"Received a {e.Message.MessageReference} message with the following fields:");
foreach (var field in e.Message.Fields)
Console.WriteLine($"{field.Key}: {field.Value}");
}

static void OnConnectionStatusChanged(object sender,
ConnectionStatusChangedEventArgs e) =>
Console.WriteLine($"{DateTime.Now.ToShortTimeString()} - " +
$"Connection Status: {e.ConnectionStatus}");
}
}
Loading

0 comments on commit b802389

Please sign in to comment.