ForeksPubsubSdk 1.0.5
See the version list below for details.
dotnet add package ForeksPubsubSdk --version 1.0.5
NuGet\Install-Package ForeksPubsubSdk -Version 1.0.5
<PackageReference Include="ForeksPubsubSdk" Version="1.0.5" />
paket add ForeksPubsubSdk --version 1.0.5
#r "nuget: ForeksPubsubSdk, 1.0.5"
// Install ForeksPubsubSdk as a Cake Addin #addin nuget:?package=ForeksPubsubSdk&version=1.0.5 // Install ForeksPubsubSdk as a Cake Tool #tool nuget:?package=ForeksPubsubSdk&version=1.0.5
ForeksPubsubSdk
This project is build to subcribe Foreks PubSub Server with .Net applications.
- **version 😗* 1.0.5
- **author 😗* ForeksCoreTeam
Dependencies
The packages listed below must be add to project with Nuget
- Newtonsoft.Json
- System.Net.Http
Quick Start
Simple explanations of the functions can be found in this section.
Deciding Options At first, options must be decided and an object instance of ConnectionOptions class must be created to connect Foreks Pubsub Server. Default constructor of this class takes destination ip, destination port, username and password. Some static functions are implemented to connect predefined destiontion ip and port
- ToDEV
- ToUAT
- ToPROD
- ToPRODSlave
ForeksPubsubSdk.ConnectionOptions connectionOptions = ForeksPubsubSdk.ConnectionOptions.ToPROD({{your_username}}, {{your_password}});
Reconnect parameter: When the connection is dropped, new connection is established automatically. Default is true;
Creating Client Secondly, an object instance of PubsubClient must be created. Object takes an object instance of connectionOptions class.
ForeksPubsubSdk.PubsubClient foreksPubsubClient = new ForeksPubsubSdk.PubsubClient(connectionOptions);
Listening Events Then, PubsubClient events must be listened.
- OnLogin
- OnHeartbeat
- onData
- OnDisconnect
- OnError
- OnMessage
- OnNotification
- OnSymbolAdd
- OnSymbolRemove
OnLogin: When the response of a login request is received this event will be triggered despite the fact that the login is succeeded. OnHeartbeat: When the server sends heartbeat message, this event will be triggered. Server heartbeat messages periodically. Client heartbeat messages are send in the background. onData: When the subscribed field is changed, server sends new data and this event will be triggered. OnDisconnect: When the connection is dropped, this event will be triggered. OnError: When the server sends Error or Unknown message, this event will be triggered. OnMessage: When the server sends global message, this event will be triggered. Not in use yet. OnNotification: When the server sends notification, this event will be triggered. OnSymbolAdd: When a symbol is added to definition, such as hot insert in BIST, this event will be triggered. Definition of the symbol will be sent. OnSymbolRemove: When a symbol is removed from definition, this event will be triggered. Definition of the symbol will be sent.
foreksPubsubClient.OnLogin += PubsubClient_OnLogin;
foreksPubsubClient.OnHeartbeat += PubsubClient_OnHeartbeat;
foreksPubsubClient.OnData += PubsubClient_OnData;
foreksPubsubClient.OnDisconnect += PubsubClient_OnDisconnect;
foreksPubsubClient.OnError += PubsubClient_OnError;
foreksPubsubClient.OnMessage += PubsubClient_OnMessage;
foreksPubsubClient.OnNotification += PubsubClient_OnNotification;
foreksPubsubClient.OnSymbolAdd += PubsubClient_OnSymbolAdd;
foreksPubsubClient.OnSymbolRemove += PubsubClient_OnSymbolRemove;
Subscription Subscribe method of an object which is an instance of PubsubClient takes to List<string> as an input parameters. First one holds the id's of the symbols which can be found in https://feed-definition.foreks.com/symbol/search Second one holds the shortCode's of the fields which are predefined in Fields class.
foreksPubsubClient.Subscribe(new List<string>() { "H1846", "H14678" }, new List<string>() { ForeksPubsubSdk.Fields.Last, ForeksPubsubSdk.Fields.DateTime });
Unsubscription
foreksPubsubClient.Unsubscribe(new List<string>() { "H1846" }, new List<string>() { ForeksPubsubSdk.Fields.Last });
Listening Data With start function, new TCP connection is created and login request is send. If the login request is succeeded, subscriptions which were set before start function are called automatically. With every incoming data related event is triggered.
foreksPubsubClient.Start();
EXAMPLE
using System;
using System.Collections.Generic;
namespace PubsubTest
{
class MainClass
{
static void ForeksPubsubClient_OnNotification(object sender, ForeksPubsubSdk.ResponseArgs e)
{
Console.WriteLine("OnNotification: " + e.ToString());
}
static void ForeksPubsubClient_OnSymbolRemove(object sender, ForeksPubsubSdk.ResponseArgs e)
{
Console.WriteLine("OnSymbolAdd: " + e.ToString());
}
static void ForeksPubsubClient_OnSymbolAdd(object sender, ForeksPubsubSdk.ResponseArgs e)
{
Console.WriteLine("OnSymbolAdd: " + e.ToString());
}
static void ForeksPubsubClient_OnError(object sender, ForeksPubsubSdk.ResponseArgs e)
{
Console.WriteLine("OnError: " + e.ToString());
}
static void ForeksPubsubClient_OnDisconnect(object sender, ForeksPubsubSdk.ResponseArgs e)
{
Console.WriteLine("OnDisconnect: " + e.ToString());
}
static void ForeksPubsubClient_OnHeartbeat(object sender, ForeksPubsubSdk.ResponseArgs e)
{
Console.WriteLine("OnHeartbeat: " + e.ToString());
}
static void ForeksPubsubClient_OnLogin(object sender, ForeksPubsubSdk.ResponseArgs e)
{
Console.WriteLine("OnLogin: " + e.ToString());
}
static void ForeksPubsubClient_OnMessage(object sender, ForeksPubsubSdk.ResponseArgs e)
{
Console.WriteLine("OnMessage: " + e.ToString());
}
static void ForeksPubsubClient_OnData(object sender, ForeksPubsubSdk.ResponseArgs e)
{
Console.WriteLine("OnData: " + e.ToString());
}
static void Main(string[] args)
{
try
{
ForeksPubsubSdk.ConnectionOptions connectionOptions = ForeksPubsubSdk.ConnectionOptions.ToPROD({{your_username}}, {{your_password}});
ForeksPubsubSdk.PubsubClient foreksPubsubClient = new ForeksPubsubSdk.PubsubClient(connectionOptions);
foreksPubsubClient.OnLogin += ForeksPubsubClient_OnLogin;
foreksPubsubClient.OnHeartbeat += ForeksPubsubClient_OnHeartbeat;
foreksPubsubClient.OnData += ForeksPubsubClient_OnData;
foreksPubsubClient.OnDisconnect += ForeksPubsubClient_OnDisconnect;
foreksPubsubClient.OnError += ForeksPubsubClient_OnError;
foreksPubsubClient.OnMessage += ForeksPubsubClient_OnMessage;
foreksPubsubClient.OnNotification += ForeksPubsubClient_OnNotification;
foreksPubsubClient.OnSymbolAdd += ForeksPubsubClient_OnSymbolAdd;
foreksPubsubClient.OnSymbolRemove += ForeksPubsubClient_OnSymbolRemove;
foreksPubsubClient.Subscribe(new List<string>() { "H1846", "H14678" }, new List<string>() { ForeksPubsubSdk.Fields.Last, ForeksPubsubSdk.Fields.DateTime });
foreksPubsubClient.Start();
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
}
while (true) { }
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.5
- Newtonsoft.Json (>= 11.0.2)
- System.Net.Http (>= 4.3.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.5 | 70 | 12/13/2024 |
2.1.4 | 153 | 9/10/2024 |
2.1.3 | 133 | 8/9/2024 |
2.1.1 | 111 | 6/13/2024 |
2.1.0 | 117 | 5/28/2024 |
2.0.1 | 733 | 9/24/2021 |
2.0.0 | 413 | 9/22/2021 |
1.0.27 | 652 | 7/20/2020 |
1.0.26 | 542 | 4/24/2020 |
1.0.25 | 586 | 3/18/2020 |
1.0.24 | 550 | 3/12/2020 |
1.0.23 | 614 | 1/29/2020 |
1.0.22 | 660 | 10/11/2019 |
1.0.21 | 620 | 8/22/2019 |
1.0.20 | 706 | 6/18/2019 |
1.0.19 | 749 | 5/24/2019 |
1.0.18 | 712 | 5/23/2019 |
1.0.17 | 889 | 1/4/2019 |
1.0.16 | 807 | 12/19/2018 |
1.0.15 | 864 | 12/10/2018 |
1.0.14 | 850 | 12/7/2018 |
1.0.13 | 914 | 12/5/2018 |
1.0.12 | 839 | 12/5/2018 |
1.0.11 | 820 | 11/26/2018 |
1.0.10 | 851 | 11/26/2018 |
1.0.9 | 837 | 11/22/2018 |
1.0.8 | 892 | 10/19/2018 |
1.0.7 | 871 | 10/16/2018 |
1.0.6 | 981 | 8/8/2018 |
1.0.5 | 950 | 8/3/2018 |
1.0.4 | 1,078 | 8/3/2018 |
1.0.3 | 951 | 8/3/2018 |
1.0.2 | 918 | 8/2/2018 |
Initial Release