-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.1.0: Performance improvements and breaking API changes.
- Loading branch information
Showing
25 changed files
with
953 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"); | ||
} | ||
} |
Oops, something went wrong.