Results 1 to 6 of 6
  1. #1
    Member
    Join Date
    Sep 2009
    Location
    London
    Posts
    14

    Data Adapter sample for COMMAND mode

    Is there any tutorial for impelementing a data adapter in .NET for COMMAND mode? It seems like PortfolioDemo has one in java but not in .Net?

  2. #2
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,

    we already made a .NET port of our Portfolio adapter
    It will be publicly available in the next release, in the meanwhile we could send it to you if you want.
    Just send me a PM asking for it and I'll send the code to you.

  3. #3
    Member
    Join Date
    Sep 2009
    Location
    London
    Posts
    14

    Hi Mone,

    I just sent you a PM.

    Thanks.

  4. #4
    Member
    Join Date
    Sep 2009
    Location
    London
    Posts
    14
    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:
    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:
    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?

  5. #5
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,

    The post you linked was written before the inclusion of the setCommandLogic method.
    It simplifies your job as without calling it updates received trhough the onItemUpdate are item-based while after correctly calling the setCommandLogic method you'll have key-based updates (basically the difference is in the meaning of the isValueChanged and getOldValue methods). Moreover the method can be used to enable the multimetapush logic (eg: see the Portfolio demo description that uses the multimetapush logic vs the simple portfolio demo that uses simple metapush).

    About your client code, after a quick look it seems correct.
    Maybe the problem lies in the metadata adapter. Which one are you using? Can you see any error on your server log?
    Did you try to change your code to connect to the default portfolio adapter?

  6. #6
    Member
    Join Date
    Sep 2009
    Location
    London
    Posts
    14
    Hi Mone,

    After half an hour of posting my message; I managed to receive data notifications (onItemUpdate fires now with correct data) and both data adapter and my client script are working as I want them to be.

    It think only reason I am not having the updates to the client was "not restarting the whole system" properly after my changes; because I wasn't able to see any error log etc.. , just onItemUpdate wasn't firing but all was ok after restarting every system component.

    Many thanks for the reply.

 

 

Similar Threads

  1. Sample code for multiple data adapter access
    By h2c357 in forum Client SDKs
    Replies: 1
    Last Post: September 8th, 2011, 09:55 AM
  2. command mode
    By Pradeep Chahal in forum Adapter SDKs
    Replies: 1
    Last Post: February 24th, 2010, 10:52 AM
  3. command mode
    By Pradeep Chahal in forum Client SDKs
    Replies: 2
    Last Post: February 15th, 2010, 11:20 AM
  4. NonVisualTable with COMMAND mode
    By Alessandro in forum Client SDKs
    Replies: 2
    Last Post: June 17th, 2009, 12:50 PM
  5. COMMAND mode
    By atnemeth in forum Client SDKs
    Replies: 3
    Last Post: May 19th, 2008, 11:19 AM

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 09:08 AM.