-
February 12th, 2010, 09:16 AM
#1
Creating Stock Quotes/Transaction application using GWT-Data not coming to the client
I am creating a sample application for both Stock Quotes and transactions (Say Order Request and Order Response or Login Request and Login Response. The response ia asynchronous). I am using SmartGWT for the browser front end and I use JSON strings from the server to the client communication. In the client I parse the JSON string and update an array of objects. This array of objects in bound to a SmartGWT Grid.
The steps involved:
1. Send Logon Request
2. Receive Logon Response from the server asynchronously.
3. Display the logon success/failure message in a separate message window (This contains a grid with a list of messages)
4. Receive the list of stocks from the server (inturn from the database) for this user
5. Subscribe all the stocks to the server
6. Receive stock updates from the server
7. Receive static details from the server (inturn from the database) for filling up combo boxes in the order entry screen (Say list of exchanges, list of stocks... etc.,)
8. Place an order request for this client to the server
9. Receive order response from the server asynchronously.
Code Written to achieve this:
1. Send Logon Request: I am creating a Key with Username + #instancesAndSecurities (Example: ODION#instancesAndSecurities) and subscribing to the LS server. When the server sends a response back to the client it uses the same key as above. The below code is called in the Init method.
$wnd.user_name = username;
var divTag = document.createElement("div");
divTag.id = "list";
divTag.setAttribute("class","marketWatchClass");
divTag.setAttribute("source","lightstreamer");
divTag.setAttribute("table","instancesAndSecuritie sTable");
divTag.setAttribute("item",username+"#instancesAnd Securities");
divTag.setAttribute("field","instancesAndSecuritie s");
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("push.chellasoftapp.co m");
engine.connection.setLSPort("9090");
engine.connection.setAdapterName("BrowserToLSToTWS ");
engine.connection.setUserName(username);
engine.connection.setPassword(password);
engine.changeStatus("STREAMING");
}
$wnd.page.bind();
$wnd.page.createEngine("BrowserToLSToTWSApp", "LS", "SHARE_SESSION", true);
$wnd.pushtable = new $wnd.OverwriteTable(null, null, "MERGE");
$wnd.chellaSoft = this;
$wnd.pushtable.onItemUpdate = function (item, updateInfo) {
if ((updateInfo == null)&&(item==null)) {
return;
}
$wnd.jsonUpdatedNative(username);
}
$wnd.page.addTable($wnd.pushtable, "instancesAndSecuritiesTable");
2. Receive Logon Response from the server asynchronously: $wnd.pushtable.onItemUpdate will get called
3. Display the logon success/failure message in a separate message window (This contains a grid with a list of messages): $wnd.jsonUpdatedNative(username);method will parse the message and display in a separate window.
4. Receive the list of stocks from the server (inturn from the database) for this user: $wnd.jsonUpdatedNative(username); method will parse the list of securities and the following function is used to subscribe the list of securities
jsonEntries = "Stock1 Stock2 Stock3 Stock4 Stock5"; //This is a sample list for better understanding. The actual list will come as a paramter to this function.
$wnd.pushtable = new $wnd.NonVisualTable(jsonEntries.split(" "), new Array("instancesAndSecurities"), "MERGE");
$wnd.pushtable.onItemUpdate = function (item, updateInfo) {
if ((updateInfo == null)&&(item==null)) {
return;
}
var val = updateInfo.getNewValue("instancesAndSecurities");
$wnd.jsonUpdatedStaticJS(val);
}
$wnd.page.addTable($wnd.pushtable, "instancesAndSecuritiesTable");
5. Subscribe all the stocks to the server: Code given in point 4.
6. Receive stock updates from the server: $wnd.jsonUpdatedStaticJS(val); method will parse the JSON string and update this to an object which will inturn refresh the SmartGWT grid.
7. Receive static details from the server (inturn from the database) for filling up combo boxes in the order entry screen (Say list of exchanges, list of stocks... etc.,):
In this case I am sending the JSON string from the server using the key ODION#instancesAndSecurities. In the client side I am NOT getting this JSON string.
Can you please point of the issue in the code?
-
February 12th, 2010, 03:20 PM
#2
Hi,
first of all, about the 1st point, in case you didn't, you should implement the getItems method of your MetaDataProvider to prevent an user to subscribe to another user's item.
that said, about your problem, it seems to me that you're trying to accomplish a system that receives a list of messages from the server. For such logic you cannot use the MERGE mode as when two updates for the same item are published quickly one after the other it is likely that only he second will reach the client as the first one is MERGEd with the other.
To publish a list of messages avoiding merge you would use a DISTINCT subscription (eg ChatDemo ). For further details check out the "General Concept.pdf" file (section 3.1) available under LS_HOME/DOCS-SDKs/ in our distribution.
About why your updates don't reach the client, I see that you use two tables but you subscribe both with the same id (the second parameter of the addTable: instancesAndSecuritiesTable). This way the second addTable make the first table to unsubscribe.
If that's not the problem, and if possible, we should start taking a look to your server logs. Please set the LightstreamerLogger.push category to log at TRACE level (and keep LightstreamerLogger.requests at INFO level). Then run your client and send us the log
-
April 9th, 2010, 01:30 PM
#3
Hi,
does merge appear if two the messages are different? For example: "message11112" and "message11113"
-
April 12th, 2010, 09:54 AM
#4
it depends on the time between the generation of the two messages and the frequency of the updates (see setRequestedMaxFrequency and the comment of the <max_delay_millis> and <max_buffer_size> elements in the server configuration file).
-
July 10th, 2010, 06:33 AM
#5
Hi Friends, I am Cine and I have read your site in a very deep and I would like to appreciate you on this brilliant effort. You have provided some thing so much different that I can't have words for thanks.
-
July 12th, 2010, 10:12 AM
#6
Dear Cine,
Thanks for your compliments! We rely on feedback from our users to keep improving.
Cheers,
Alessandro
Similar Threads
-
By pradeepgamage in forum General
Replies: 1
Last Post: January 9th, 2012, 11:39 AM
-
By rd2008 in forum Client SDKs
Replies: 8
Last Post: February 11th, 2009, 12:13 PM
-
By lucab617 in forum Adapter SDKs
Replies: 5
Last Post: May 19th, 2008, 03:16 PM
-
By tuongkha in forum Adapter SDKs
Replies: 4
Last Post: January 15th, 2008, 09:15 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
All times are GMT +1. The time now is 10:48 AM.
Bookmarks