Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Mar 2010
    Location
    Madurai
    Posts
    12

    Error: createEngine() has already been called

    I am using following code to connect my JAVA web application to Light Streamer

    Code:
    public native static void init(String username, String password)
    	/*-{
    		$wnd.user_name = username;		
    		var divTag = document.createElement("div");
    		divTag.id = "list";
    
    		divTag.setAttribute("class","ClassName");
    		divTag.setAttribute("source","lightstreamer");
    		divTag.setAttribute("table","TableName");
    		divTag.setAttribute("item",username+"#TableName");
    		divTag.setAttribute("field","FieldName");
    		divTag.style.display = 'none'; 
    		document.body.appendChild(divTag);
    
    		$wnd.page = new $wnd.PushPage();
    		$wnd.page.context.setDomain("chellasoftapp.com"); 
    		$wnd.page.onEngineCreation = function(engine) {
    			$wnd.lsEngine = engine;
    
    			engine.connection.setLSHost("domainName.com"); 
    			engine.connection.setLSPort("port"); 
    			
    			engine.connection.setAdapterName("AdapterName");						
    
    			engine.connection.setUserName(username);
    			engine.connection.setPassword(password);
    
    			engine.changeStatus("STREAMING");
    		}
    
    		$wnd.page.bind();		
    		$wnd.page.createEngine("AdapterName", "LS", "SHARE_SESSION", true);
    
    		var itemName = username+"#iTableName";
    		$wnd.pushtable = new $wnd.NonVisualTable(itemName, new Array("TableName"), "DISTINCT");
    		$wnd.chellaSoft = this;
    		$wnd.pushtable.onItemUpdate = function (item, updateInfo) {
    			$wnd.jsonUpdatedStaticJS(updateInfo.getNewValue("FieldName"));
    		}
    
    		$wnd.page.addTable($wnd.pushtable, "TableName");
    	}-*/;
    I had called this method, once the user submit his/her user name and password.
    On first time suppose user type mistype his password. And this methord will called and create the engine without any issue. But, then he type the correct password and submit the details it throws the following error.

    “3: 18:0:18,438 ER createEngine createEngine() has already been called” .

    please advise me how to overcome to this error? Or give me any other suggestions.

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,089
    In fact, the Engine can only be created once.
    Your init function creates the Engine, supplies the credentials, starts streaming and subscribes to a table altogether.
    If you have to change the password afterwards, then you should do it separately, by acting on the Engine pointer you have saved, and by just
    1. disconnecting (although the previous STREAMING attempt with the wrong credentials probably failed);
    2. setting the new password on the Engine object
    3. requesting STREAMING again

    Note that the table subscription is also kept by the library, so you don't need to repeat it when requesting STREAMING the second time.

  3. #3
    Member
    Join Date
    Mar 2010
    Location
    Madurai
    Posts
    12
    Hi

    Thank you very much for your reply,
    Following are my queries as a newbie on here (it may very simple one),

    How to disconnect the engine? I tried to access the engine object out side of this method. But all of my effort lead me on wrong path (I think).

    Yes, as you said, creates the Engine, supplies the credentials, starts streaming and subscribes to a table altogether. Due to I have no idea about, how to access the engine object out side this function I keep all the effort in one place. Kindly advice me, how to split this method too. Thank you.

  4. #4
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,089
    A pointer to the Engine is received when your onEngineCreation callback is invoked by Lightstreamer library.
    I see that the callback saves the pointer to $wnd.lsEngine;
    this is the pointer you can use afterwards to invoke all methods targeted to the Engine,
    like: $wnd.lsEngine.changeStatus("DISCONNECTED") to disconnect.
    If you did that, it should have worked.

    Note that the general way of managing the lifecycle of the Engine pointer is slightly different and has to be followed in case you have multiple pages sharing the Engine; it consists of:
    • implementing the onEngineReady callback and saving the pointer there (onEngineReady is similar to onEngineCreation, but it is invoked also when the page already finds an Engine and just shares it).
    • implementing the onEngineLost callback to just clear the pointer (in fact, if a different page holds the shared Engine and gets closed, the Engine may be temporarily unavailable to the other pages).


    I didn't really mean that your init method had better be split.
    In general, the PushPage and Engine initialization code is separated from the table creation and subscription code. After creating and configuring the PushPage object, you can save the pointer (as you do, in $wnd.page) and use it later when you generate the cells on the page and create the Table object.

 

 

Similar Threads

  1. createEngine should be in the BODY ??
    By mohamida in forum Client SDKs
    Replies: 10
    Last Post: August 18th, 2010, 01:50 PM
  2. createEngine should be in the BODY ??
    By mohamida in forum Client SDKs
    Replies: 10
    Last Post: August 18th, 2010, 01:50 PM
  3. notifySessionClose sometimes not being called
    By lstest in forum Adapter SDKs
    Replies: 2
    Last Post: February 24th, 2010, 12:09 PM
  4. Table.onEndOfSnapshot not being called
    By jweber in forum Client SDKs
    Replies: 10
    Last Post: February 10th, 2010, 10:25 AM
  5. Data Adapter's subscribe() method not getting called
    By CitiMan in forum Adapter SDKs
    Replies: 8
    Last Post: November 30th, 2006, 05:26 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 03:12 AM.