public void TestUserStory() { //1: Create a session provider AppKeyAndSessionProvider sessionProvider = new AppKeyAndSessionProvider( AppKeyAndSessionProvider.SSO_HOST_COM, AppKey, UserName, Password); //2: Create a client Client client = new Client( "stream-api-integration.betfair.com", 443, sessionProvider); //3: Create a cache ClientCache cache = new ClientCache(client); //4: Setup order subscription //Register for change events cache.OrderCache.OrderMarketChanged += (sender, arg) => Console.WriteLine("Order:" + arg.Snap); //Subscribe to orders cache.SubscribeOrders(); //5: Setup market subscription //Register for change events cache.MarketCache.MarketChanged += (sender, arg) => Console.WriteLine("Market:" + arg.Snap); //Subscribe to markets (use a valid market id or filter) cache.SubscribeMarkets("1.125037533"); Thread.Sleep(5000); //pause for a bit }
private static void InitialSetup() { //betfair connection var provider = new AppKeyAndSessionProvider(ConfigurationManager.AppSettings["ssoHost"], ConfigurationManager.AppSettings["appKey"], ConfigurationManager.AppSettings["userName"], ConfigurationManager.AppSettings["password"]); var session = provider.GetOrCreateNewSession(); Client = new JsonRpcClient(_url, session.AppKey, session.Session); //Betfair Hub var url = string.Format(ConfigurationManager.AppSettings["ratingsFile"], DateTime.Today); using (var client = new WebClient()) { var ratings = client.DownloadString(url); System.IO.File.WriteAllText($"ratings-{DateTime.Now:yyyyMMddHHmm}.json", ratings); Ratings = JsonConvert.DeserializeObject <Ratings>(ratings); } LoadMarkets(); var startTimeSpan = TimeSpan.FromMinutes(2); var periodTimeSpan = TimeSpan.FromMinutes(2); var timer = new System.Threading.Timer((e) => { LoadMarkets(); }, null, startTimeSpan, periodTimeSpan); }
public static void NewSessionProvider(string ssohost, string appkey, string username, string password) { var sessionProvider = new AppKeyAndSessionProvider(ssohost, appkey, username, password); SessionProvider = sessionProvider; }
public bool Login(string username, string password, string ssoHostName = "identitysso.betfair.com") { AppKeyAndSessionProvider authProvider = new AppKeyAndSessionProvider(ssoHostName, appKey, username, password); networkClient = new Client(streamEndPointHostName, 443, authProvider); networkClient.ChangeHandler = this; networkClient.Start(); return(true); }
/// <summary> /// Construct a new client to the specified host and port /// </summary> /// <param name="hostName"></param> /// <param name="port"></param> /// <param name="sessionProvider"></param> public Client(string hostName, int port, AppKeyAndSessionProvider sessionProvider) { _hostName = hostName; _port = port; _sessionProvider = sessionProvider; _processor = new RequestResponseProcessor(SendLine); _processor.ConnectionStatusChanged += DispatchConnectionStatusChanged; //default properties AutoReconnect = true; Timeout = TimeSpan.FromSeconds(30); ReconnectBackOff = TimeSpan.FromSeconds(15); KeepAliveHeartbeat = TimeSpan.FromHours(1); }
public bool Login(string username, string password, string ssoHostName = "identitysso.betfair.com") { AppKeyAndSessionProvider authProvider = new AppKeyAndSessionProvider(ssoHostName, appKey, username, password); networkClient = new Client(streamEndPointHostName, 443, authProvider); networkClient.ChangeHandler = this; networkClient.Start(); return true; }