Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    Nov 2011
    Location
    Mty
    Posts
    10

    Question Bandwidth in iOS

    It is possible to use a property which can handle the net traffic. I mean if i have 3 light streamer connection every one used for get their own information. I need to reduce the flow because so much traffic makes my app becomes slow.

    After show light streamer table I need to operate another stuffs, when i want to do something else, the app freezes for hundredths of seconds.

    you can make me another suggestions.

    Thanks!!

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

    You have different options:

    - first of all, I would suggest to use just one Lightstreamer connection and subscribe multiple items on it. It will greatly reduce the overhead due to connection monitoring and handling;

    - second, you can unsubscribe items not currently shown (i.e.: subscribe them on viewWillAppear and unsubscribe them on viewDidDisappear), which will reduce both the data traffic and the CPU usage;

    - last but not least, Lightstreamer has plenty of features to fine tune the data throughput, and the two most important are maxBandwidth on LSConnectionConstraints and requestedMaxFrequency on LSTableInfo. If your app is consuming too much CPU time processing updates, you may try to reduce the number of updates with these two parameters.

    Hope this helps.
    Best regards,

    Gianluca

  3. #3
    Member
    Join Date
    Nov 2011
    Location
    Mty
    Posts
    10

    thanks

    Hi Gianluca, thanks for your advises. My name Is Ivanhoe.

    Could I give you more information about this;.

    I have tried with the second option that you gave me, before that you wrote it. But unfortunately it doesn't stop the connection, when i use
    [_my@class unsubscribeItems]; it keeps running. I guess this is my best option for the future, because if i want to show another view i need to stop the connection.

    The first point depends of the second, I guess that I made a terrible mistake when we start to program the app, we use a lot of view controllers in just one class which is not a view controller. I mean in my main class we call all of view and present it. this make hard to solve the problem (stop the connection).

    the last point, could you give an example about how use maxBandwidth, because i seen it, but i couldn't make it works. i just did this;

    [LSConnectionConstraints constraintsWithMaxBandwidth:100.0];


    It is probably that you need more information about my class. I really need help with this.
    I really appreciate if you lend my a hand, you are too kind!!

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

    have a look at the StockList Demo for iOS code, which is included in the Lightstreamer distribution. You will notice in the StockListViewController an unsubscribeItems method. This method is called only when the app enters background mode, but if you add a little button somewhere that calls this method you will see it does stop the subscription. Calling the subscribeItems will restart the subscription.

    My suggestion for you is to refactor your code so that you can selectively subscribe and unsubscribe your items entering and exiting specific view controllers, similarly to what the StockList Demo does. Besides this, the Lightstreamer library has no way to guess what you are putting on the screen, if it's not you that stop the subscriptions the library surely can't.

    About connection constraints, the right way to use them is to create an LSConnectionConstraints, set the maxBandwidth in kbit/sec and then either: add it to a LSConnectionInfo (method setConstraints) during the initial setup of the Lightstreamer connection, or use it to change an open connection (method changeConnectionWithConstraints of LSClient). For example:

    LSConnectionConstraints *constraints= [[LSConnectionConstraints alloc] init];
    constraints.maxBandwidth= 10.0;
    [myClient changeConnectionWithConstraints:constraints];

    Hope this helps.
    Best regards,

    Gianluca

  5. #5
    Member
    Join Date
    Jul 2012
    Location
    Nuevo Leon
    Posts
    4
    thanks a lot for the information Gianluca.

    I have checked Stock List for iOS Demo, I modified almost everything in the app even I added two buttons, one for stop and other for start.
    I guess, I am miss something about delegate or something like that, because I use the same structure which is used in Demo about unsubscribe and it doesn't work, I don't know what else could I check.

    About the LSConnection It works fine, thanks. I just one to tell you if you have seen a mistake when you use LSConnection. Because it show me an error when i use it, it says something about the connection to push server, is not ready and then the app crash it.

    this is the method where i declared;

    - (void) connectToLightstreamer
    {
    _client= [[LSClient alloc] init];
    LSConnectionConstraints *constraints= [[LSConnectionConstraints alloc] init];
    constraints.maxBandwidth= 10.0;
    LSConnectionInfo *connectionInfo= [LSConnectionInfo connectionInfoWithPushServerURL:SERVER_URL pushServerControlURL:nil user:nil password:nil adapter:@"EMISORAS"];
    [_client openConnectionWithInfo:connectionInfo delegate:self];
    [_client changeConnectionWithConstraints:constraints];
    }


    kind regards!!

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

    change your method in this way:

    - (void) connectToLightstreamer {

    _client= [[LSClient alloc] init];

    LSConnectionConstraints *constraints= [[LSConnectionConstraints alloc] init];
    constraints.maxBandwidth= 10.0;

    LSConnectionInfo *connectionInfo= [LSConnectionInfo connectionInfoWithPushServerURL:SERVER_URL pushServerControlURL:nil user:nil password:nil adapter:@"EMISORAS"];
    connectionInfo.constraints= constraints;

    [_client openConnectionWithInfo:connectionInfo delegate:self];
    }


    Best regards,

    Gianluca

  7. #7
    Member
    Join Date
    Jul 2012
    Location
    Nuevo Leon
    Posts
    4
    Hi Gianluca!!

    I really appreciate your help, you are too kind!!

    The connection error, I think is gone. I haven't seen it again.

    About the table view. Do you remember when I told you that I have 3 views, every one contains a table view. I know the program structure is completely wrong. But my question is, Would it be possible when I call every unsubscribe method, the _tableKey doesn't release it? maybe because it doesn't know the name of the table. I mean they have the same name "_tableKey".

    I rechecked the sample of StockList .appDelegate specifically. When I push HOME it calls the method unsubscribe, but when I debugged it, it doesn't get into unsubscribe method, so I uncomment NSLog Line and it was not written in console either.

    What do you think it is happening with the unsubscribe method? I can not finish to understand the way it works.

    Kind Regards!!

    Ivanhoe

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

    apply the following changes to the StockList Demo app in the StockListViewController class file:

    - add the following lines at the very beginning of the infoTapped method:

    if (!_tableKey)
    [self subscribeItems];
    return;


    - add the following lines at the very beginning of the statusTapped method:

    if (_tableKey)
    [self unsubscribeItems];
    return;


    Now run the app and verify that pressing the status button (the green sphere) will stop the subscription, and pressing the info button will restart it. You can stop and restart it how many times you want.

    Best regards,

    Gianluca

 

 

Similar Threads

  1. AMF and Consuming Network Bandwidth?
    By ernivan in forum Client SDKs
    Replies: 1
    Last Post: March 11th, 2011, 10:35 AM
  2. Bandwidth and event pushing
    By churrusco in forum General
    Replies: 10
    Last Post: May 8th, 2007, 03:04 PM

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
  •  
All times are GMT +1. The time now is 01:11 PM.