EnvironmentManager.Instance.SendMessage increases the number of sent messages after refresh Management Client

I need to send messages from Management Client and receive them in the background. And it works well.

But when I refresh the Management Client, next time I receive 2 of the same sent messages in the background. Each time I refresh the Management Client, the number of received messages in the background increases by 1.

By debugging, I found that the SendMessage function is not called multiple times in Management Client.

When I restart the Management Client, the process starts all over again, working fine until the first refresh. So I don’t think it’s a problem in Background.

We assume if MessageIdFilter is implemented correctly. (MessageIdFilter is a filter for receiving a certain message, for example: the local memory copy of the configuration is updated). Can you please check it?

https://doc.developer.milestonesys.com/html/index.html?base=miphelp/class_video_o_s_1_1_platform_1_1_messaging_1_1_message_id_filter.html&tree=tree_search.html?search=messageidfilter

In the specific example, which I am sending you attached, I have a communication filter registration that only happens once in the background, and an example of a Enviroment.Instance.SendMessage function that is sent from the Management Client to check connection state.

Communication filter registration (Background):

registrationSend message function (Management Client):

sendMessage

VideoOS.Platform.Messaging.MessageCommunication.WaitForCommunicationFilterRegistration means using the cross-process message communication, while the EnvironmentManager.Instance.SendMessage is inter-process communication within the Management Client. I think there is a mix-up here and you should use one or the other. Using VideoOS.Platform.EnvironmentManager.RegisterReceiver might be the better choice.

The issue is something else, I think.

A Management Client refresh will reload, meaning re-initialize plugins, so if you register but never unregister you will build up more objects.

Is your background in the Management Client or elsewhere?

Where do you in your plugin register? Where do you in your plugin unregister?

My background runs only from the event server and there are registration. Registration occurs only once in the Init function and unregister occurs in the Close function in background.

Target environments of background plugin:

Screenshot_1As far as I understand the problem is not in the background, because when the Management Client is restarted, Send Message works normally until it is refreshed.

Below I send you the parts of the log that I print when the message is received in background.

On Management Client start (works fine):

log_startOn Management Client first refresh I got 2 messages:

log_firstRefreshOn second refresh:

log_secondRefreshOn Management Client restart (everything works fine again until next refresh):

log_afterRestartNote: Event Server (background) has not been restarted or refreshed.

Could you please change your sender to use MessageCommunication.TransmitMessage instead of EnvironmentManager.Instance.SendMessage? The SendMessage is generally only meant to be used for local communication whereas MessageCommunication is for cross-application communication.

I changed. Now everything works fine.

Thanks a lot.