-
November 25th, 2008, 11:34 AM
#1
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?
-
November 26th, 2008, 09:27 AM
#2
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
-
By finodex in forum Adapter SDKs
Replies: 5
Last Post: May 14th, 2012, 01:47 PM
-
By igindex in forum Client SDKs
Replies: 1
Last Post: October 27th, 2009, 04:50 PM
-
By quanhm in forum General
Replies: 1
Last Post: November 16th, 2007, 11:32 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
All times are GMT +1. The time now is 09:49 AM.
Bookmarks