Mone, many thanks for the source code.
I was missing "listener.EndOfSnapshot(itemName);" on my data adapter implementation but adding that didin't solve my problem.
I am basically trying to implement a NonVisualTable with COMMAND mode; and I tried to benefit from below link:
http://79.125.12.202/vb/showthread.php?t=63
However, Although I can see that my subscription is successfull and data being passed to LS by calling listener.Update(...), I am not able to receive anything on the client. (onItemUpdate doesn't fire)
My javascript code:
function SubscribeToTradeData(clientAccountId) {
var pushPage = getPushPage();
var schema = new Array("key", "command", "marketId", "name", "qty", "tradePrice", "currently");
var group = new Array(LSSubscriptionTables.ClientTrades.Prefix + clientAccountId);
var clientTradesTable = new NonVisualTable(group, schema, "COMMAND");
clientTradesTable.setDataAdapter("TradingAdapter");
clientTradesTable.setSnapshotRequired(true);
clientTradesTable.onItemUpdate = function(item, itemUpdate) {
console.log("item: " + item);
//Some debug code here for itemUpdate
}
pushPage.addTable(clientTradesTable, LSSubscriptionTables.ClientTrades.Name);
}
If I change "COMMAND" to "MERGE", onItemUpdate event fires (only once though) so I know that adapter settings etc.. are correct.
My publishing c# code:
public void Publish(string itemName, IList<TradeDTO> tradeDtos)
{
Publish(itemName, tradeDtos, false);
}
public void PublishSnapshot(string itemName, IList<TradeDTO> tradeDtos)
{
Publish(itemName, tradeDtos, true);
//Notify Lightstreamer for end of snapshot
listener.EndOfSnapshot(itemName);
log.Info("End of snapshot for: " + itemName);
}
public void Publish(string itemName, IList<TradeDTO> tradeDtos, bool isSnapshot)
{
if (IsConnected)
{
foreach (var tradeDto in tradeDtos)
{
log.WarnFormat("Broadcasting --> ItemName: {0} , Trade Id: {1} , Market Id: {2} , Market Name: {3}", itemName, tradeDto.TradeId, tradeDto.MarketId, tradeDto.MarketName);
listener.Update(itemName, CreateDataToSend(tradeDto, isSnapshot ? BroadcastingCommand.Add : BroadcastingCommand.Update), isSnapshot);
}
}
else
{
log.WarnFormat("Not connected, unable to publish {0}.", tradeDtos);
}
}
I tried to set the command logic but I am not sure I need it. Any idea what I am missing?