Results 1 to 2 of 2
  1. #1
    Senior Member
    Join Date
    Sep 2008
    Location
    rmd
    Posts
    30

    stopping, restarting connection

    In my case, user need not to get updates all the time; when ever he stops receiving real time data, i wanna stop the connection and should restart it whenever he wants.

    i use following to remove a table, when he presses the stop button.
    if (lsPage.getTable(tableId)) lsPage.removeTable(tableId);
    lsPage = null;
    when he press restart i call following,
    lsPage = new PushPage();

    lsPage.onEngineCreation = function(engine) {
    engine.connection.setLSHost("mydomain/push");
    engine.connection.setLSPort(null);
    engine.connection.setAdapterName("MyAdapter");
    engine.changeStatus("STREAMING");
    };
    lsPage.bind();

    lsPage.createEngine("MyEngine", "../ls");

    //lsPage.addTable(////);

    when i do it, it throws an exception(client side) stating that
    "createEngine() has already been called";

    If i dont recreate the engine this doesnt happen obviously.

    my original requirement is to keep the connection only when he requires it.
    is there any way to totally disconnect from the server when he doesnt need it. ( even i set lsPage as null, it tries to keep the connection. [for example it shows in firebug "GET STREAMING IN PROGRESS" when i stop the lightstreamer server]) Could you please assist me in this, so that i can stop/start connection when it is required?

    will it be able to do it by changing the status to disconnected, when he stops? if so, could you please give me some code snippet to stop the server, coz i'm struggling to do it for a long time?

  2. #2
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hello,

    to disconnect a client from the server you should call the changeStatus method of the LightstreamerEngine object:

    First of all you should store the LightstreamerEngine instance as soon as it is made available through the onEngineReady callback:


    then you can use such reference to disconnect whenever you want


    Note that you should always check that the pointer to the engine is still valid before use it, this is because initially you don't have any reference and because once the onEngineLost callback is called you should dismiss such instance:


    Obviously you can reconnect changing the parameter of the changeStatus method to "STREAMING".

    Please also note that you can leave the tables "inside" the PushPage instance (ie the call of removeTable is not needed if you plan to resubscribe the same tables once the connection restarts) and that you should not delete your PushPage instance.

    Hope that helps.

 

 

Similar Threads

  1. Replies: 5
    Last Post: May 14th, 2012, 02:47 PM
  2. Stopping update rendering when using OverwriteTable
    By igindex in forum Client APIs
    Replies: 1
    Last Post: October 27th, 2009, 05:50 PM
  3. Problem with stopping LS server in Linux
    By quanhm in forum General
    Replies: 1
    Last Post: November 16th, 2007, 12:32 PM

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 12:52 AM.