Can anybody send me any sample code for subscribing to lightstreamer with LSCommand mode
Thank You.
Printable View
Can anybody send me any sample code for subscribing to lightstreamer with LSCommand mode
Thank You.
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?
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
Thank you @DarioCrivelli.
@gianluce.bertani I want a sample code when server push updates in didUpdateWithInfo (delegate method).
Thank You
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