Results 1 to 10 of 22

Hybrid View

  1. #1
    Senior Member
    Join Date
    Sep 2007
    Location
    des plaines
    Posts
    41
    Here is my latest code. I understand that you are not supporting .Net but still maybe you can give me a hint:

    using System.Collections;
    using System.Threading;
    using System;
    using System.Runtime.InteropServices;
    using Lightstreamer.Interfaces.Data;
    using System.Windows.Forms;

    public class SocketToLightStreamer : IDataProvider
    {
    private IItemEventListener _listener;
    public void Init(IDictionary parameters, string configFile)
    {
    }

    public bool IsSnapshotAvailable(string itemName)
    {
    return false;
    }

    public void SetListener(IItemEventListener eventListener)
    {
    _listener = eventListener;
    }
    public void Subscribe(string itemName)
    {
    if (itemName.Equals("floorupdate"))
    {
    }
    }

    public void Unsubscribe(string itemName)
    {
    if (itemName.Equals("floorupdate"))
    {
    }
    }
    public void PushData(string data)
    {
    IDictionary eventData = new Hashtable();
    eventData["scan"] = data;
    _listener.Update("floorupdate", eventData, false);
    }
    public class GetMessage : Form
    {
    const int WM_COPYDATA = 0x004a;

    public GetMessage()
    {
    Text = "my_unique_id";
    }

    protected override void WndProc(ref System.Windows.Forms.Message m)
    {
    switch (m.Msg)
    {
    case WM_COPYDATA:
    COPYDATASTRUCT mystr = new COPYDATASTRUCT();
    Type mytype = mystr.GetType();
    mystr = (COPYDATASTRUCT)m.GetLParam(mytype);
    IDictionary eventData = new Hashtable();
    eventData["scan"] = mystr.Data;
    SocketToLightStreamer a = new SocketToLightStreamer();
    a._listener.Update("floorupdate", eventData, false);
    break;
    }
    base.WndProc(ref m);
    }
    }
    [StructLayout(LayoutKind.Sequential)]
    public struct COPYDATASTRUCT
    {
    public Int32 ID;
    public int Length;
    public string Data;
    }
    }
    While this code is compiling fine when I run it I get:
    "null reference" at a._listener.Update("floorupdate", eventData, false);
    Wold you suggest to how to have a form inside of SocketToLightStreamer class in a way that I could access _listener object from it?

    Thanks for the hep.

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,091
    The SocketToLightStreamer class should not be instantiated directly.
    Exactly one object of this class is internally created by the Lightstreamer Remote Adapter Library.
    If you get data from outside code, as your GetMessage class seems to be, you should be able to access that object.

    Usually, the Data Adapter class starts the feed in "Init" and asks it for data in "Subscribe". There, it can send its own reference to the feed.
    This is not your case, as you feed data regardless of the subscription requests
    (note that any updates you send while no subscription is active will be lost).

    What you could do, for instance, is have your SocketToLightStreamer object assign itself to a static pointer that can be eventually consulted in GetMessage.
    Note that the best place to assign the pointer is after setting the listener in "SetListener".
    Also note that synchronization issues may need to be considered.

  3. #3
    Administrator
    Join Date
    Jul 2006
    Location
    Milan, Italy
    Posts
    521
    Hi Mark,

    Please let me clarify that we do support .NET. In particular, Lightstreamer Moderato (the free edition) includes the SDK for .NET Adapter, while Lightstreamer Allegro/Presto/Vivace (the commercial editions) include the SDK for .NET clients too. All the SDKs we provide are supported.

    Cheers
    Alessandro

  4. #4
    Senior Member
    Join Date
    Sep 2007
    Location
    des plaines
    Posts
    41
    <Also note that synchronization issues may need to be considered.
    And that I think I am having a problem with. I am running a process that stupidely sends current time with an interval of one second to push to the cient. I see that sometimes (not that bad though) I am missing some data. What would you suggest?

    Thanks

  5. #5
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,091
    I warned about synchronization issues with relation to my suggestion of putting a pointer to the Data Adapter on a static variable. I did it just in case.
    If you, after revising your code, can now see that some updates do reach the client, I cant' figure how synchronization problems could cause single updates to be lost.

    It is possible that some events are merged by the Server, if bandwidth or frequency restrictions are configured.
    You can check the event flow through the Server in the Server log, after setting the priority for the "LightstreamerLogger.subscriptions" and "LightstreamerLogger.pump" categories to DEBUG in "lightstreamer_log_conf.xml".

  6. #6
    Senior Member
    Join Date
    Sep 2007
    Location
    des plaines
    Posts
    41
    Here is my latest code with which I am missing some data sometimes:
    using System.Collections;
    using System.Threading;
    using System;
    using System.Runtime.InteropServices;
    using Lightstreamer.Interfaces.Data;
    using System.Windows.Forms;

    public class SocketToLightStreamer : IDataProvider
    {
    private IItemEventListener _listener;
    public void Init(IDictionary parameters, string configFile)
    {
    }

    public bool IsSnapshotAvailable(string itemName)
    {
    return false;
    }

    public void SetListener(IItemEventListener eventListener)
    {
    _listener = eventListener;
    }
    public void Subscribe(string itemName)
    {
    if (itemName.Equals("floorupdate"))
    {
    Form f = new GetMessage(this);
    f.Show();
    f.Hide();
    ApplicationContext ctx = new ApplicationContext();
    Application.Run(ctx);
    }
    }

    public void Unsubscribe(string itemName)
    {
    if (itemName.Equals("floorupdate"))
    {
    }
    }
    public void PushData(string data)
    {
    System.Console.WriteLine(data);
    IDictionary eventData = new Hashtable();
    eventData["scan"] = data;
    _listener.Update("floorupdate", eventData, false);
    }
    public class GetMessage : Form
    {
    const int WM_COPYDATA = 0x004a;
    private SocketToLightStreamer clientUpdater;
    public GetMessage(SocketToLightStreamer o)
    {
    Text = "my_unique_id";
    clientUpdater = o;
    }

    protected override void WndProc(ref System.Windows.Forms.Message m)
    {
    switch (m.Msg)
    {
    case WM_COPYDATA:
    COPYDATASTRUCT mystr = new COPYDATASTRUCT();
    Type mytype = mystr.GetType();
    mystr = (COPYDATASTRUCT)m.GetLParam(mytype);
    new Thread(delegate() { clientUpdater.PushData(mystr.Data); }).Start();
    break;
    }
    base.WndProc(ref m);
    }
    }
    [StructLayout(LayoutKind.Sequential)]
    public struct COPYDATASTRUCT
    {
    public Int32 ID;
    public int Length;
    public string Data;
    }
    }

    I see missing data in the Console written in PushData method.

    Here is sample of data being lost:
    22-Aug-08 08:19:41,266 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 1 |Pumping event in session Sa4839d7557b06b92T1742762: d(1,1,1,"08:19:40^text2\u000D");
    22-Aug-08 08:19:42,266 |TRACE|LightstreamerLogger.subscriptions|#1 Notify Receiver |INCOMING DATA for floorupdate --> {scan=08:19:41^text1
    }
    22-Aug-08 08:19:42,266 |DEBUG|LightstreamerLogger.subscriptions|#1 Notify Receiver |Manager: com.lightstreamer.e.s@8046f4
    22-Aug-08 08:19:42,266 |TRACE|LightstreamerLogger.pump |PUMP POOLED THREAD 1 |Pumping event in session Sa4839d7557b06b92T1742762: d(1,1,1,"08:19:41^text1\u000D");
    22-Aug-08 08:19:43,376 |TRACE|LightstreamerLogger.subscriptions|#1 Notify Receiver |INCOMING DATA for floorupdate --> {scan=08:19:43^text2
    }

  7. #7
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,091
    If I understand well, you are complaining about the absence of an event for 08:19:42.
    The log shows that such event is missing in the flow from the Data Adapter, hence it is not filtered because of bandwidth or frequency restrictions.
    However, I cannot find any evidence in the Data Adapter code that an event for 08:19:42 was supposed to be generated, as it seems that part of the event production process takes place externally. Moreover, I notice that the last "INCOMING DATA" event in the log file happens significantly more than one second after the preceding one.

    So, the Remote Data Adapter part is now to be logged.
    If you find it useful, you can enable logging by Lightstreamer libraries on the Remote Server, by configuring a <log4net> session in a way similar to the
    DOCS-SDKs\sdk_adapter_dotnet\examples\DotNetStockListDe mo\Deployment\Deployment_DotNet_Server\dotnet_1.1\ DotNetServer.exe.config
    file. Just set DEBUG level for the Lightstreamer.DotNet.Server.RequestReply logger to have the Update calls logged.

    Just in case, note that the field values of your events (like "08:19:41^text1\u000D", the trailing being a return character) seem to lack some processing.

  8. #8
    Senior Member
    Join Date
    Sep 2007
    Location
    des plaines
    Posts
    41
    I am going to follow your recomdations but I think the reason for missing data is that sometimes data push by the LS takes just a moment longer (means resources are still busy) and my data adapter does not have a chance to process, hence it does not provide avery data for to LS for data push. That was the reason to have actual code for data push into another thread. It seamed helped but not for 100%.
    What do you think about that?
    BTW, My data is just a test data, but missings also happen with the real data that does not have a "^" symbol.

    Thanks for your help.

 

 

Similar Threads

  1. Database Feed
    By mode_vigilante in forum Adapter SDKs
    Replies: 16
    Last Post: January 27th, 2012, 03:58 PM
  2. .NET web service as Data Feed
    By icaiozzi in forum Adapter SDKs
    Replies: 1
    Last Post: November 19th, 2010, 11:52 AM
  3. How to deploy on an external Web Server?
    By AndyKelly in forum Client SDKs
    Replies: 1
    Last Post: July 7th, 2010, 10:50 AM
  4. How And Where To Specify Database As Data Feed?
    By devidasan in forum Adapter SDKs
    Replies: 1
    Last Post: March 17th, 2009, 11:00 AM
  5. External deployment
    By markgoldin in forum General
    Replies: 6
    Last Post: September 28th, 2007, 01:15 PM

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 03:22 PM.