Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: Action script

  1. #1
    Member
    Join Date
    Jul 2009
    Location
    Zagreb
    Posts
    18

    Action script

    Greetings I'm new here and I have a question. I'm working on application that allows steraming of data between two endpoints. I took example data adapter created by Mone and adapted it to read from file and push the data. (I read one value - double, and cast it to string and do it at regular intervals - values is always different). I managed to do it without errors and all is fine but I'm stuck at making client application that accepts the incoming data and extracts that one value and stores it for use by other part of program that draws a graph from available data. Now I would use the example again supplied by Mone and adapt it a little but don't know even where to start with writing! Can I do it in eclipse or what?
    (sry for the noob questions but it is a project in college and I will flunk if I don't complete it and this is my first time using any of this. I'm sort of good in Java but knowledge in javascript or action script or flex and similar things is next to none )

  2. #2
    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>

  3. #3
    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

  4. #4
    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

  5. #5
    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

  6. #6
    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.

  7. #7
    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.

  8. #8
    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.

  9. #9
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    it seems that you've shut down immediately the server
    16-srp-09 13:47:03,265 |INFO |LightstreamerLogger.init |Thread-12 |Server shutdown requested
    sorry not to mention it, you should start the server, open your page on a browser, wait a little bit and then get the log so that we can see what requests reach the server and how it answers.

  10. #10
    Member
    Join Date
    Jul 2009
    Location
    Zagreb
    Posts
    18
    ok I got the server to send something. Problem indeed was with the client. Here's proof that he is transmitting:

    16-srp-09 14:51:19,953 |INFO |LightstreamerLogger.license |main |This is a trial version.
    16-srp-09 14:51:21,437 |INFO |LightstreamerLogger.init |main |Lightstreamer Server starting in Vivace edition
    16-srp-09 14:51:21,484 |INFO |LightstreamerLogger.init |main |Started HTML Adaptor for JMX on port 6666
    16-srp-09 14:51:21,531 |INFO |LightstreamerLogger.init |main |Started JMXMP Connector for JMX on port 9999
    16-srp-09 14:51:21,625 |INFO |LightstreamerLogger.init |main |data_provider element without name attribute; using DEFAULT as the default name
    16-srp-09 14:51:21,625 |INFO |LightstreamerLogger.init |Init for SIMPLEST |Loading Metadata Adapter SIMPLEST
    16-srp-09 14:51:21,625 |INFO |LightstreamerLogger.init |Init for SIMPLEST.DEFAULT |Loading Data Adapter SIMPLEST.DEFAULT
    16-srp-09 14:51:21,625 |INFO |LightstreamerLogger.init |Init for SIMPLEST.DEFAULT |Finished loading Data Adapter SIMPLEST.DEFAULT
    16-srp-09 14:51:21,625 |INFO |LightstreamerLogger.init |Init for SIMPLEST |Finished loading Metadata Adapter SIMPLEST
    16-srp-09 14:51:21,687 |INFO |LightstreamerLogger.init |main |Pump pool size set by default at 2
    16-srp-09 14:51:21,734 |INFO |LightstreamerLogger.init |main |Events pool size set by default at 2
    16-srp-09 14:51:21,750 |INFO |LightstreamerLogger.init |main |Lightstreamer Server 3.5 build 1428.4 starting...
    16-srp-09 14:51:21,796 |INFO |LightstreamerLogger.init |main |Server "Lightstreamer HTTP Server" listening to *:8080 ...
    16-srp-09 14:51:35,265 |INFO |LightstreamerLogger.requests |SERVER POOLED THREAD 8 |Serving request: /lightstreamer/create_session.js?LS_phase=1702&LS_polling=true&LS _polling_millis=0&LS_idle_millis=30000&LS_client_v ersion=4.3&LS_adapter=SIMPLEST& from 127.0.0.1:1728
    16-srp-09 14:51:35,421 |TRACE|LightstreamerLogger.pump |SERVER POOLED THREAD 8 |Pump for session S259eca68b19bc589T5135421 added
    16-srp-09 14:51:35,453 |INFO |LightstreamerLogger.requests |SERVER POOLED THREAD 8 |Starting new session: S259eca68b19bc589T5135421 from 127.0.0.1:1728
    16-srp-09 14:51:35,484 |INFO |LightstreamerLogger.requests |SERVER POOLED THREAD 2 |Serving request: /lightstreamer/STREAMING_IN_PROGRESS?LS_session=S259eca68b19bc589 T5135421&LS_phase=1703& from 127.0.0.1:1733
    16-srp-09 14:51:35,500 |INFO |LightstreamerLogger.requests |SERVER POOLED THREAD 2 |Attaching session: S259eca68b19bc589T5135421 from 127.0.0.1:1733
    16-srp-09 14:51:37,515 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 2 |Sending probe in session S259eca68b19bc589T5135421
    16-srp-09 14:51:39,515 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 1 |Sending probe in session S259eca68b19bc589T5135421
    16-srp-09 14:51:41,515 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 2 |Sending probe in session S259eca68b19bc589T5135421
    16-srp-09 14:51:43,515 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 1 |Sending probe in session S259eca68b19bc589T5135421
    16-srp-09 14:51:45,515 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 2 |Sending probe in session S259eca68b19bc589T5135421
    16-srp-09 14:51:47,515 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 1 |Sending probe in session S259eca68b19bc589T5135421
    16-srp-09 14:51:49,515 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 2 |Sending probe in session S259eca68b19bc589T5135421
    16-srp-09 14:51:51,515 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 1 |Sending probe in session S259eca68b19bc589T5135421
    16-srp-09 14:51:53,515 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 2 |Sending probe in session S259eca68b19bc589T5135421
    16-srp-09 14:51:55,515 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 1 |Sending probe in session S259eca68b19bc589T5135421
    16-srp-09 14:53:02,515 |TRACE|LightstreamerLogger.pump |FOR PUMPS PARKING DESTROYER|Pump for session S259eca68b19bc589T5135421 removed
    But I still get only loading. Looks like client is not interpreting correctly.

    Here is NEW 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 id="F|table1|stream|Next|div" class="">loading...</div>


    <script>




    var page = new PushPage();
    page.onEngineCreation = function(engine) {
    engine.connection.setAdapterName("SIMPLEST");
    engine.changeStatus("STREAMING");
    }
    page.bind();
    page.createEngine("SimplestApp", "LS", "SHARE_SESSION");

    var pushtable = new OverwriteTable(stream, null, "DISTINCT");
    page.addTable(pushtable, "table1");



    </script>
    </body>

    </html>
    And now I get error that there are no elements in table table1

 

 

Similar Threads

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