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

    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:

    Code:
    - (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?

    Thanks!

    /afb

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Location
    Bologna
    Posts
    42
    Hello,

    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,

    Gianluca

 

 

Similar Threads

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

Tags for this Thread

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
  •  
Powered by vBulletin® Version 4.2.0
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
All times are GMT +1. The time now is 06:18 PM.