0

I'm developing an application that needs to receive events from cameras(eg. motion detection) using ONVIF protocol.

I've downloaded the latest ONVIF Device Manage version from link, and was able to compile and run it.

I would like to create something similar to DeviceEventsView.xaml of Onvif Device Manager in my own source using the libraries provided, however I'm having a tough time figuring out what part of the code is from the library itself.

Can someone be so kind as to explain me how it can be done?

Here's what I manage to do so far(this code might be completely wrong):

OdmSession session = new OdmSession(this.session);
IObservable<OnvifEvent> x = session.GetBaseEvents(554);
x.Subscribe(
    onvifEvent =>
    {
        try
        {
            // don't know exactly what to do here
        }
        catch (Exception err)
        {
            dbg.Error(err);
        }
    }, err =>
    {
        dbg.Error(err);
    }
);
user3154369
  • 139
  • 1
  • 3
  • 13

1 Answers1

0

I'm gonna answer my own question. Here's the code that solved my problem:

onvif.utils.OdmSession odmSession = new onvif.utils.OdmSession(session);
odmSession.GetPullPointEvents().Subscribe(
    onvifEvent =>
    {
        try
        {
            foreach (var s in onvifEvent.message.Data.simpleItem)
            {
                if (s.name == "LogicalState")
                {
                    // code here
                }
            }
        }
        catch (Exception e)
        {
            MessageBox.Show(e.Message);
        } 
});
user3154369
  • 139
  • 1
  • 3
  • 13