rd2008
According to my understanding, onEngineReady is an event that triggers when the engine page is created. It doesn't make any sense about whether the webclient is successfully connected to the server. [even the server is not running it will trigger onEngineReady]
Is there a straight method to know exactly when the client is connected with the server, rather than periodically check the engine status[some thing like onServerConnected ]?
Originally I want delay the addTable until I verify that the server is ready to subscribe. Is there any communication between webclient and server even before adding any push table or it starts communication right after adding any table?
Thanks.
P:S: Can you please post the sequence of communication between webclient and server to clarify this better.
Dario Crivelli
We can't produce a detailed chart of the scenario in short time. Please, see the notes below.
When the Engine is first created, the onEngineCreation callback is invoked and no connection attempt to the Server is performed. It is invoked only to one page, therefore this is the place in which you can ask for the connection, by calling changeStatus("STREAMING").
Then, the onEngineReady callback is invoked for all pages, so as to allow each page to get a pointer to the Engine object.
This, indeed, happens concurrently with (i.e. either before or after) the connection to the Server.
Once provided with a pointer to the Engine, a page can know the connection status through getStatus and can be informed through onStatusChange (where STREAMING and POLLING mean "connected", DISCONNECTED and CONNECTING mean "not connected" and STALLED means "not sure it is still connected; let's see what happens").
Hence, a suggested code may be the following:
[SYNTAX="JS"]var connected = false;
pushPage.onEngineReady = function(lsEngine) {
lsEngine.onStatusChange = function(newStatus) {
connected = (newStatus == "STREAMING" || newStatus == "POLLING" || newStatus == "STALLED");
};
// take the current engine status into account
lsEngine.onStatusChange(lsEngine.getStatus());
};
pushPage.onEngineLost = function() {
connected = false;
};[/SYNTAX]
Adding push tables is also independent with respect to the connection to the Server.
You can add and remove tables at any time. If the connection is not active, adding table does not request a connection; however, as soon as the connection is requested through changeStatus, the table subscription is forwarded to the Server.
Hence, there should be no need to delay adding tables.