Hi,
so let's modify the
buysell.jsfile of the
PortfolioDemo (source code available in the Lightstreamer distribution).
First of all let's implement the MessageListener interface:
[syntax="JS"]function MyMessageListener(num) /*implements Lightstreamer.MessageListener*/ {
this.id = num;
}
MyMessageListener.prototype={
onAbort: function() {
alert("mex " + this.id + " aborted");
},
onDeny: function(code,err) {
alert("mex " + this.id + " denied " + code + " - " + err);
},
onDiscarded: function() {
alert("mex " + this.id + " discarded");
},
onError: function() {
alert("mex " + this.id + " error");
},
onProcessed: function() {
alert("mex " + this.id + " processed");
}
};[/syntax]
our simple implementation will simply alert us of the result of the request.
Then let's use it in the submitForm method.
First we need a simple counter to identify the messages, so declare a "next" var before the submitForm method:
[syntax="JS"]var next = 0;
function submitForm(op) {
var name = document.getElementById("stockN");
...[/syntax]
then create a MyMessageListener instance per each message and pass it to the sendMessage method
[syntax="JS"] ...
var mex = op + "|" + portfolioId + "|" + name + "|" + qtyN;
var mexListener = new MyMessageListener(++next);
engineRef.sendMessage(mex, "Orders", mexListener, 30000);
}
}[/syntax]
Obviously you'll implement the MessageListener interface to fit your needs :Smile_Ab:
That's all.
HTH