Moving to Streaming in VB.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lopiner
    Junior Member
    • Feb 2009
    • 117

    #1

    Moving to Streaming in VB.net

    Hi to everyone.

    I'm trying to move to Market Streaming but unfortunately i'm only comfortable with VB.net and the main sample code is in C#. Main Sample code i'm referring is in this link. I tried to convert it but i wasn't able to do it.

    From what i can understand the Solution has 4 Projects:
    • BetFair ESA Client
    • BetFair ESA Client Test
    • BetFair ESA Console App
    • BetFair ESA Swagger


    The two in the middle just seem to be solutions showing how to use the main code which i believe is in the other two. The "BetFair ESA Client" and the "BetFair ESA Swagger" from what i understand can be compiled into libraries and be used in a VB.net project.

    I created a project in VB.net and imported the two dll's:
    • Betfair.ESAClient.dll
    • Betfair.ESASwagger.dll


    Then i followed the instruction on the GitHub page of the project and tried to convert them to Vb.net:

    I have this three declarations, one with the login info, one where i create a connection ("client") and the third one with what the dev team calls a "cache". The code is the following:

    Code:
            Dim sessionProvider As New AppKeyAndSessionProvider(AppKeyAndSessionProvider.SSO_HOST_COM, "MyAppKey", "MyUserName", "MyPassword")
            Dim client As New Client("stream-api-integration.betfair.com", 443, sessionProvider)
            Dim cache As New ClientCache(client)
    I think the cache class is a big class that holds methods for subscribing to Markets and Orders and where there are response handlers that dump the initial image on objects and then manages any incremental messages. If anyone can confirm this it will be great, just so i can better understand how the whole thing is built, thanks.

    After those three initial lines the Github introductions have this commands in C# to subscribe to markets and orders:

    Code:
     //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");
    I don't know how to convert this code.
    I think the next logical step would be to subscribe to order with a possible filter, subscribe to markets also with a filter and then declare two routines to catch events. Not really sure how to do it, any help would be appreciated. Thanks
    fooledbyabet.com
  • Grantay.
    Junior Member
    • Jan 2010
    • 53

    #2
    C#->vb

    Code:
    '4: Setup order subscription
    'Register for change events
    cache.OrderCache.OrderMarketChanged += Function(sender, arg) Console.WriteLine("Order:" + arg.Snap)
    'Subscribe to orders    
    cache.SubscribeOrders()
    
    '5: Setup market subscription
    'Register for change events
    cache.MarketCache.MarketChanged += Function(sender, arg) Console.WriteLine("Market:" + arg.Snap)
    'Subscribe to markets (use a valid market id or filter)
    cache.SubscribeMarkets("1.125037533")

    Comment

    • Lopiner
      Junior Member
      • Feb 2009
      • 117

      #3
      Originally posted by Grantay. View Post
      Code:
      '4: Setup order subscription
      'Register for change events
      cache.OrderCache.OrderMarketChanged += Function(sender, arg) Console.WriteLine("Order:" + arg.Snap)
      'Subscribe to orders    
      cache.SubscribeOrders()
      
      '5: Setup market subscription
      'Register for change events
      cache.MarketCache.MarketChanged += Function(sender, arg) Console.WriteLine("Market:" + arg.Snap)
      'Subscribe to markets (use a valid market id or filter)
      cache.SubscribeMarkets("1.125037533")
      Thanks GRANTAY for the tip.
      I tried some C# to VB.net converters that gave me the same result but that syntax is invalid in VB.net (they often come short when converting more complex code).
      Can anyone help? Thanks
      fooledbyabet.com

      Comment

      Working...
      X