Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012
    San Francisco

    Subscribing to multiple items

    I'm new to LS and am confused as to the proper approach to subscribe to multiple items with different fields using the iOS client API.

    Right now I am able to subscribe to multiple items with identical fields, using the following syntax:

    - (void)connectToLightstreamer {
    	client = [LSClient client];
        LSConnectionInfo *connectionInfo = [LSConnectionInfo connectionInfoWithPushServerURL:LS_SERVER_URL pushServerControlURL:nil user:LS_API_KEY password:nil adapter:LS_ADAPTER];
    	[client openConnectionWithInfo:connectionInfo delegate:self];
    - (void) clientConnection:(LSClient *)client didStartSessionWithPolling:(BOOL)polling {
        if (!tableKey)
    		[self performSelector:@selector(subscribeItems) withObject:nil afterDelay:0.1];
    - (void)subscribeItems {
        @try {
            NSArray *itemNames = [MyObjectClass itemList];
            NSArray *fieldNames = [MyObjectClass fieldList];
            LSExtendedTableInfo *tableInfo = [LSExtendedTableInfo extendedTableInfoWithItems:itemNames mode:LSModeMerge fields:fieldNames dataAdapter:@"TEST" snapshot:YES];
            tableInfo.requestedMaxFrequency = 0.05;
            tableKey = [client subscribeTableWithExtendedInfo:tableInfo delegate:self useCommandLogic:NO];
            NSLog(@"Table subscribed");
        } @catch (NSException *e) {
    		NSLog(@"Table subscription failed due to exception: %@", e);
    This works fine. But what I don't understand is what the syntax would be for subscribing to additional items that have a schema (in the general sense, not the LS sense) that is different from the items in itemList above. I suppose I could just add different item types to itemNames and additional field names to fieldNames, but I feel like that could result in namespace collision or other problems if I had two different item types that happened to share a field name.

    Can you clarify the proper practice for the case of subscribing to different types of items?



  2. #2
    Join Date
    Feb 2012
    Bologna, Italy

    you may simply create more than one subscription: for each item create a separate table info, with its item name and appropriate field list, and subscribe it individually. The delegate callback carries the table key as a parameter, you will be able to recognize which subscription has been updated by checking it.

    Hope this helps.
    Best regards,




Similar Threads

  1. Problem re-subscribing
    By colmfield in forum Client SDKs
    Replies: 5
    Last Post: July 13th, 2010, 02:37 PM
  2. Subscribing to the Table
    By AidasOzelis in forum Client SDKs
    Replies: 13
    Last Post: June 3rd, 2010, 01:13 PM
  3. having problem while subscribing pairs
    By rekhender in forum Adapter SDKs
    Replies: 1
    Last Post: October 31st, 2008, 09:58 AM

Tags for this Thread


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 06:51 AM.