Results 1 to 5 of 5

Hybrid View

  1. #1

    LS iOS LSCommand mode sample

    Can anybody send me any sample code for subscribing to lightstreamer with LSCommand mode

    Thank You.

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,090
    I confirm that we don't provide such sample.

    Examples of the use of COMMAND mode on the client side are only available for other libraries;
    I refer, for instance, to the Basic Portfolio Demo and the Full Portfolio Demo, in pages\demos\PortfolioDemo_Basic and pages\demos\PortfolioDemo respectively.

    In libraries more similar to the iOS case, there are just code samples which show the use of the APIs in the COMMAND mode case;
    see, for instance, DOCS-SDKs\sdk_client_dotnet\examples\test\TestClient.cs and look for "command".

    Do you have doubts on specific aspects?

  3. #3
    Administrator
    Join Date
    Feb 2012
    Location
    Bologna, Italy
    Posts
    102
    Hello,

    a sample subscription would be something like this:


    LSExtendedTableInfo *tableInfo= [LSExtendedTableInfo extendedTableInfoWithItems:[NSArray arrayWithObjects:@"portfolio1", nil]
    mode:LSModeCommand
    fields:[NSArray arrayWithObjects:@"command", @"key", @"qty", nil]
    dataAdapter:@"PORTFOLIO_ADAPTER"
    snapshot:YES];

    LSSubscribedTableKey *tableKey= [_client subscribeTableWithExtendedInfo:tableInfo delegate:self useCommandLogic:YES];


    If you have specific doubts don't hesitate to ask.
    Best regards,

    Gianluca

  4. #4
    Thank you @DarioCrivelli.

    @gianluce.bertani I want a sample code when server push updates in didUpdateWithInfo (delegate method).

    Thank You


  5. #5
    Administrator
    Join Date
    Feb 2012
    Location
    Bologna, Italy
    Posts
    102
    As my colleague Dario said before, we don't have a full example for command logic in Objective-C. On the didUpdateWithInfo event you should take the command, key and any other relevant data and apply them to your local copy of current data. E.g.:


    // Take command and data from update
    NSString *command= [updateInfo currentValueOfFieldName:@"command"];
    NSString *key= [updateInfo currentValueOfFieldName:@"key"];
    NSString *qty= [updateInfo currentValueOfFieldName:@"qty"];

    if ([command isEqualToString:@"UPDATE"]) {
    // Update qty on item <key>

    } else if ([command isEqualToString:@"ADD"]) {
    // Add new item <key> and set qty

    } else if ([command isEqualToString:@"DELETE"]) {
    // Remove item <key>
    }

    // Update visuals


    Hope this helps.
    Best regards,

    Gianluca

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 05:14 PM.