Send Analytic Event in MultiEnvironment

Hi,

I’m working on a windows application that manages multiple Milestone servers.

Now I need to trigger some analytic events on different servers.

In the sample this is achieved using EnvironmentManager SendMessage.

But I think this approach doesn’t meet my needs because I don’t see any way to choose the server to send the event to.

Is there another way to send an event?

Thank you,

Gianluca

The EnvironmentManager.SendMessage will only use what it considers to be the main Event Server (ES).

Instead you will have to use MessageCommunication.

I recommend that you explore the Multi-Site Status Viewer sample.

In this sample a collection of sites/ES is created. In the sample a TransmitMessage sends a ProvideCurrentStateRequest, similarly you can send a NewEventCommand.

https://doc.developer.milestonesys.com/html/index.html?base=miphelp/class_video_o_s_1_1_platform_1_1_messaging_1_1_message_id_1_1_server.html&tree=tree_2.html

Alternatively you can use the newer RESTful Events API, but also here you will have different endpoints for each site.

https://doc.developer.milestonesys.com/mipvmsapi/api/events-rest/v1/

Thank you for the support.

I’m trying to go with the MessageCommunication, but actually I am not able to send the event.

I tried also to test it changing the sample code of AnalyticsEventTrigger to use MessageCommucation, but i get the same exception: Unable To Transmit - Discarding message ‘Server.NewEventCommand’ as sending Indication and Command messages are not allowed.

I changed the sample code in this way:

EventSource eventSource = new EventSource()

{

    // Send empty - it is possible to send without an eventsource, but the intended design is that there should be a source

    // the FQID is primamry used to match up the ObjectId with the a camera.

    FQID = \_selectedItem.FQID,

    // If FQID is null, then the Name can be an IP address, and the event server will make a lookup to find the camera

    Name = \_selectedItem.Name

};

EventHeader eventHeader = new EventHeader()

{

ID = Guid.NewGuid(),

Type = “Ganimede”,

Timestamp = DateTime.Now,

Message = txtAnalyticsEventName.Text,

    Source = eventSource,

CustomTag = “TagFromC#”

};

AnalyticsEvent analyticsEvent = new AnalyticsEvent();

analyticsEvent.EventHeader = eventHeader;

analyticsEvent.Location = “Event location 1”;

analyticsEvent.Description = “Analytics event description.”;

analyticsEvent.Vendor = new Vendor();

analyticsEvent.Vendor.Name = “My Smart Video”;

if (chkIncludeOverlay.Checked)

{

analyticsEvent.ObjectList = new AnalyticsObjectList();

analyticsEvent.ObjectList.Add(GetRectangle());

}

  //EnvironmentManager.Instance.SendMessage(

  // new VideoOS.Platform.Messaging.Message(MessageId.Server.NewEventCommand)

  // { Data = analyticsEvent });

  MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId);

  MessageCommunication messageCommunication = MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId);

  messageCommunication.TransmitMessage(

    new VideoOS.Platform.Messaging.Message(MessageId.Server.NewEventCommand) { Data = analyticsEvent },

    null, null, null);

I really hope you can help me.

Thank you.

I am very sorry that the first answer from us was not correct, you cannot use MessageCommunication.

We talked about this with MIP SDK developers and there is another recommendation that is to use AlarmCommandClient.AddEvent (getting alarm client through AlarmClientManager). This will work but we have not tested it due to lack of resource, but can you please try it out?

This seems to be the right way to go. Now I can send events and with proper rules they are promoted to alarms in milestone system. I’ll update you after proper tests on a federated environment.