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>