@admin @administrators
PLz suggest what do, to get live feed for any token from nse_fo in C#..
I m not getting any response from WriteResult function and program remains there for no output...
Attached Code Below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using AngelBroking;
namespace ConsoleApp_WS_Test2
{
class Program
{
static void Main(string[] args)
{
string Client_code = ""; //YOUR CLIENT CODE
string Password = ""; //YOUR PAS SWORD
string api_key = "";
string JWTToken = ""; //optional
string RefreshToken = ""; //optional
SmartApi connect = new SmartApi(api_key, JWTToken, RefreshToken);
OutputBaseClass obj = new OutputBaseClass();
//Login by client code and password
obj = connect.GenerateSession(Client_code, Password);
AngelToken sagr = obj.TokenResponse;
//Get Token
obj = connect.GenerateToken();
sagr = obj.TokenResponse;
AngelBroking.WebSocket _WS = new AngelBroking.WebSocket();
var exitEvent = new ManualResetEvent(false);
_WS.ConnectforStockQuote(sagr.feedToken, Client_code);
Console.WriteLine("WS Created");
if (_WS.IsConnected())
{
Console.WriteLine("IsConnected : In");
string script = "nse_fo|49364", TASK = "mw"; // SCRIPT: nse_cm|2885, mcx_fo|222900 TASK: mw|sfi|dp
Console.WriteLine("TASK : Market Watch mw");
_WS.RunScript(sagr.feedToken, Client_code, script, TASK);
_WS.MessageReceived += WriteResult;
//_WS.Close(true); //to stop and close socket connection
}
Console.WriteLine("IsConnected : Out");
exitEvent.WaitOne();
}
static void WriteResult(object sender, MessageEventArgs e)
{
Console.WriteLine("Tick Received : " + e.Message);
}
}
}