Receive events in Administrator Plugin

Hi,

I’m trying to develop a Milestone plugin for my own application and I use the AccessControl sample as an example.

In my plugin I have a background plugin running in the Event server where i connect to my own application server and wait for notification on my own systems variables.

When I receive a notification, I try to send an EventIndication to my Admin plugin to update its interface.

My problem is that I’m not receiving anything in my Admin plugin.

this is the code I use in my background plugin to send events:

EventSource eventSource = new EventSource()
            {
                FQID = _item.FQID,
                Name = _item.Name
            };
            EventHeader eventHeader = new EventHeader()
            {
                ID = Guid.NewGuid(),
				Class = "NewEventToRule",
				Type = "MyEventType",
				Timestamp = DateTime.Now,
				Message = "myEventMessage",
				Name = "MyEventName",
				Source = eventSource
            };
 
            EventSequence eventSequence = new EventSequence();
            eventSequence.StartDateTime = DateTime.Now;
            eventSequence.EndDateTime = DateTime.Now;
 
            EventData eventData = new EventData()
            {
                EventHeader = eventHeader,
                EventSequence = eventSequence
            };
 
            EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.Server.NewEventIndication) { Data = eventData });

and this is the code I use in the ItemManager of my Admin plugin to receive the events:

MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId);
 
            _messageCommunication = MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId);
 
            _myAlarmReceier = _messageCommunication.RegisterCommunicationFilter(MyNewAlarmMessageReceived, new VideoOS.Platform.Messaging.CommunicationIdFilter(VideoOS.Platform.Messaging.MessageId.Server.NewEventIndication));

Am I doing something wrong??

Two first debug ideas (newer tried this in a Administration plugin myself) -

If you run the SCOverlayOnEvent sample do you see the events? (Would verify that you are sending correctly.)

Did you put this in a background plugin which executes in the EnvironmentType.Administration ? (Can you verify that the code runs?)

No it is in a background plugin that only executes EnvironmentType.Services.

Does it have to be EnvironmentType.Administration for the administration plugin to receive the event?

Anyway, thank you for the answer, ill try what you suggested.

I overlooked your comment on the code being in the ItemManager..

Another idea: Maybe you find further in the logs- (Ref. MIP Documentation -Getting Started -Plug-in Development)

Log File Locations

XProtect Corporate Management Client:

%ProgramData%\

Milestone\

XProtect Corporate Management Client\

Logs\

MIPtrace.Log

XProtect Enterprise Management Application:

%ProgramData%\

Milestone\

Milestone Surveillance\

MIPyyyyMMdd.log

XProtect Smart Client:

%ProgramData%\

Milestone\

MIPlog.txt

XProtect Event Server:

%ProgramData%\

Milestone\

XProtect Event Server\

Logs\

Cyyyy-MM-dd.log

Events are sent, I can see them on the SCOverlayOnEvent. I looked at the logs but I can’t see anything special, the events seem to be send well.

In debug mode I see that I can register to new events but I just don’t manage to receive them in my ItemManager class in my Administration plugin and I really don’t understand what I’m missing.

I will try this out, maybe I will make the same observation as you have. Quick question: Are you working on a Management Client ot a Management Appplication? What version is the XProtect you are testing with?

Managment Application, XProtect Enterprise 2014, version 8.6a

If you manage to make it work, can you send me your code sample? Cause I really can’t make it work on my side.

I am afraid I did not make it work. I have escalated the case to get some help from Milestone Development. I will update this question when I have news from Development.

For Enterprise, the issue is that the plugin’s ItemManager.Init is called before the application is up.

Change the code to wait for the ApplicationLoggedOn message, like:

public override void Init()

{

EnvironmentManager.Instance.RegisterReceiver(ApplicationUp,

new

MessageIdFilter(MessageId.System.ApplicationLoggedOnIndication));

}

private object ApplicationUp(VideoOS.Platform.Messaging.Message

message, FQID destination, FQID sender)

{

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

_messageCommunication =

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

_myAlarmReceier =

_messageCommunication.RegisterCommunicationFilter(MyNewAlarmMessageReceived,

new

VideoOS.Platform.Messaging.CommunicationIdFilter(VideoOS.Platform.Messaging.MessageId.Server.NewEventIndication));

return null;

}

private object

MyNewAlarmMessageReceived(VideoOS.Platform.Messaging.Message message, FQID

destination, FQID sender)

{

MessageBox.Show(message.ToString());

return null;

}

Then it works.

(I have tested with Corporate - and it pop_up with many messages, no issue.)

Thank you so much, I’ll try that as soon as I can.