Results 1 to 10 of 31

Thread: Action script

Hybrid View

  1. #1
    Member
    Join Date
    Jul 2009
    Location
    Zagreb
    Posts
    18
    Quote Originally Posted by Cyro
    ...
    nvm the question. I got it to work. BUT when I try http://localhost:8080/Simplest I just get Loading and nothing moves. I don't know is it actually streaming or not. If you've got a little time here's the code:
    Data adapter:
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.Reader;
    import java.io.StreamTokenizer;
    import java.util.HashMap;
    import java.util.Map;

    import com.lightstreamer.interfaces.data.DataProvider;
    import com.lightstreamer.interfaces.data.DataProviderExce ption;
    import com.lightstreamer.interfaces.data.FailureException ;
    import com.lightstreamer.interfaces.data.ItemEventListene r;
    import com.lightstreamer.interfaces.data.SubscriptionExce ption;

    public class Simplest implements DataProvider {

    private ItemEventListener listener;
    private Map<String, ItemThread> threads = new HashMap<String, ItemThread>();

    public void init(Map params, File configDir) throws DataProviderException {
    }


    public boolean isSnapshotAvailable(String itemName)
    throws SubscriptionException {
    return false;
    }


    public void setListener(ItemEventListener listener) {
    this.listener = listener;
    }



    public synchronized void subscribe(String itemName, boolean needsIterator)
    throws SubscriptionException, FailureException {
    if (itemName.equals("stream")) {
    ItemThread it = new ItemThread(itemName);
    it.start();

    /*ItemThread it = threads.get(itemName);
    if (it == null) {
    it = new ItemThread(itemName);
    it.start();
    threads.put(itemName, it);
    */}

    }


    public synchronized void unsubscribe(String itemName) throws SubscriptionException,
    FailureException {

    ItemThread it = threads.get(itemName);
    if (it != null) {
    it.close();
    threads.remove(itemName);
    }
    }


    class ItemThread extends Thread {

    private final String item;
    private volatile boolean go = true;

    public ItemThread(String item) {
    this.item = item;
    }

    public void run() {
    int i=0;
    while(go) {
    Map<String,String> data = new HashMap<String,String>();
    try {Reader r = new BufferedReader(new FileReader("primjer.txt"));
    StreamTokenizer stok = new StreamTokenizer(r);
    stok.parseNumbers();
    // double sum = 0;
    stok.nextToken();
    while (stok.ttype != StreamTokenizer.TT_EOF) {
    if (stok.ttype == StreamTokenizer.TT_NUMBER)
    i++;
    if(i%3==2){
    data.put("Sljedeca vrijednost:", Double.toString(stok.nval));
    listener.update(item, data, false);
    try {
    Thread.sleep(1000);
    } catch (InterruptedException e) {
    }
    }

    }

    stok.nextToken();
    }
    catch(Exception e){e.printStackTrace();}

    }}
    public void close() {
    go = false;
    }
    }


    }
    Client:
    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta>
    <script language="JavaScript" src="LS/lscommons.js"></script>
    <script language="JavaScript" src="LS/lspushpage.js"></script>
    </head>

    <body>
    <h1>Simplest</h1>

    <div>
    Stream
    <span source="lightstreamer" table="table1" item="stream" field="Sljedeca vrijednost:">Loading...</span>

    </div>


    <script>



    /////////////////PushPage Configuration


    var lsPage = new PushPage();
    var debugAlerts = false;
    var remoteAlerts = false;
    var pushHost = null;
    var pushPort = null;
    var useDomain = null;

    lsPage.context.setDomain(useDomain);
    lsPage.context.setDebugAlertsOnClientError(debugAl erts);
    lsPage.context.setRemoteAlertsOnClientError(remote Alerts);

    lsPage.onEngineCreation = function(lsEngine) {
    lsEngine.context.setDebugAlertsOnClientError(debug Alerts);
    lsEngine.context.setRemoteAlertsOnClientError(remo teAlerts);

    lsEngine.connection.setLSHost(pushHost);
    lsEngine.connection.setLSPort(pushPort);
    lsEngine.connection.setAdapterName("SIMPLEST");

    lsEngine.changeStatus("STREAMING");
    }

    lsPage.bind();
    lsPage.createEngine("SimplestEng","LS","SHARE_SESS ION");

    ///////////////////////Table configuration



    var table1 = new OverwriteTable(stream, null, "RAW");
    table1.setClearOnDisconnected(true);
    table1.setClearOnRemove(true);
    lsPage.addTable(table1, "table1");



    </script>
    </body>

    </html>

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

    Assuming that field/item/adapter names are correct (check the server log to see if there are errors) I can see only one error:

    the variable stream is not defined anywhere so that the above call throws an exception. You should substitute it with one of the following:

    specifying the list of items to be subscribed:


    specifying null so that the table will read the item list from the associated html element(s):



    For javascript debug I advice you to use firefox with the firebug plugin.
    HTH

  3. #3
    Member
    Join Date
    Jul 2009
    Location
    Zagreb
    Posts
    18
    I tryed the line you gave me and nothing new happened. Problem is that server doesn't list any errors, data adapter didn't list any errors before compiling or after for that matter and Evrsoft front page tried to open the page and didn't list any problems. BUT... Field still says loading and nothing moves... I even tried to copy your entire Simplest data adapter and client and that too didn't budge. Just stands there looking pretty. I think that word Loading will forever stay etched in my mind

  4. #4
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    did you debug the adapter code? (you can debug it following this guide: http://www.lightstreamer.com/vb/showthread.php?t=145 )

    then try to paste here a snippet from your server log

  5. #5
    Member
    Join Date
    Jul 2009
    Location
    Zagreb
    Posts
    18
    no debugging errors. not one. but still no luck. page can be opened in browser but looks like either data adapter is not streaming OR client is not recieving because I get the page with heading and everything but instead of data I still get Loading.

  6. #6
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Please get a detailed log from the Server, after setting the priorities for the "LightstreamerLogger.subscriptions" and "LightstreamerLogger.pump" categories as DEBUG in the Server log configuration file (LS_HOME/conf/lightstreamer_log_conf.xml) and then paste it here.

  7. #7
    Member
    Join Date
    Jul 2009
    Location
    Zagreb
    Posts
    18
    Is this what you need?

    16-srp-09 13:44:56,734 |INFO |LightstreamerLogger.license |main |This is a trial version.
    16-srp-09 13:44:58,703 |INFO |LightstreamerLogger.init |main |Lightstreamer Server starting in Vivace edition
    16-srp-09 13:44:58,984 |INFO |LightstreamerLogger.init |main |Started HTML Adaptor for JMX on port 6666
    16-srp-09 13:44:59,109 |INFO |LightstreamerLogger.init |main |Started JMXMP Connector for JMX on port 9999
    16-srp-09 13:44:59,312 |INFO |LightstreamerLogger.init |main |data_provider element without name attribute; using DEFAULT as the default name
    16-srp-09 13:44:59,312 |INFO |LightstreamerLogger.init |Init for SIMPLEST |Loading Metadata Adapter SIMPLEST
    16-srp-09 13:44:59,328 |INFO |LightstreamerLogger.init |Init for SIMPLEST.DEFAULT |Loading Data Adapter SIMPLEST.DEFAULT
    16-srp-09 13:44:59,359 |INFO |LightstreamerLogger.init |Init for SIMPLEST.DEFAULT |Finished loading Data Adapter SIMPLEST.DEFAULT
    16-srp-09 13:44:59,359 |INFO |LightstreamerLogger.init |Init for SIMPLEST |Finished loading Metadata Adapter SIMPLEST
    16-srp-09 13:44:59,640 |INFO |LightstreamerLogger.init |main |Pump pool size set by default at 2
    16-srp-09 13:44:59,750 |INFO |LightstreamerLogger.init |main |Events pool size set by default at 2
    16-srp-09 13:44:59,812 |INFO |LightstreamerLogger.init |main |Lightstreamer Server 3.5 build 1428.4 starting...
    16-srp-09 13:45:00,000 |INFO |LightstreamerLogger.init |main |Server "Lightstreamer HTTP Server" listening to *:8080 ...
    16-srp-09 13:46:18,718 |INFO |LightstreamerLogger.license |main |This is a trial version.
    16-srp-09 13:46:20,125 |INFO |LightstreamerLogger.init |main |Lightstreamer Server starting in Vivace edition
    16-srp-09 13:46:20,171 |INFO |LightstreamerLogger.init |main |Started HTML Adaptor for JMX on port 6666
    16-srp-09 13:46:20,218 |INFO |LightstreamerLogger.init |main |Started JMXMP Connector for JMX on port 9999
    16-srp-09 13:46:20,312 |INFO |LightstreamerLogger.init |main |data_provider element without name attribute; using DEFAULT as the default name
    16-srp-09 13:46:20,312 |INFO |LightstreamerLogger.init |Init for SIMPLEST |Loading Metadata Adapter SIMPLEST
    16-srp-09 13:46:20,312 |INFO |LightstreamerLogger.init |Init for SIMPLEST.DEFAULT |Loading Data Adapter SIMPLEST.DEFAULT
    16-srp-09 13:46:20,328 |INFO |LightstreamerLogger.init |Init for SIMPLEST.DEFAULT |Finished loading Data Adapter SIMPLEST.DEFAULT
    16-srp-09 13:46:20,328 |INFO |LightstreamerLogger.init |Init for SIMPLEST |Finished loading Metadata Adapter SIMPLEST
    16-srp-09 13:46:20,390 |INFO |LightstreamerLogger.init |main |Pump pool size set by default at 2
    16-srp-09 13:46:20,437 |INFO |LightstreamerLogger.init |main |Events pool size set by default at 2
    16-srp-09 13:46:20,453 |INFO |LightstreamerLogger.init |main |Lightstreamer Server 3.5 build 1428.4 starting...
    16-srp-09 13:46:20,515 |INFO |LightstreamerLogger.init |main |Server "Lightstreamer HTTP Server" listening to *:8080 ...
    16-srp-09 13:47:03,265 |INFO |LightstreamerLogger.init |Thread-12 |Server shutdown requested
    16-srp-09 13:47:03,265 |INFO |LightstreamerLogger.init |Thread-12 |Exiting.....
    I would dare to say that problem is with client.

 

 

Similar Threads

  1. IE script warning
    By jonasby1 in forum Client SDKs
    Replies: 3
    Last Post: July 27th, 2011, 09:58 AM
  2. Replies: 5
    Last Post: December 23rd, 2010, 08:34 AM
  3. Unresponsive Script
    By vaduganathan in forum Client SDKs
    Replies: 1
    Last Post: March 23rd, 2010, 02:38 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 08:33 PM.