I have a workspace plugin inside the smart client were the user select a camera from an item-picker.
From the selected camera, is it possible to fetch the cameras IP Address in some way?
Ive seen it should be possible to do inside “component plugin” with event server version >3.1a. I tried to use those messages and receviers anyway but “message.data” that should contain the IP is null.
As i said ive looked at this example. But this is a standalone component?
The thing i do is i create a dll-file, drop it inside the milestone “file-plugin-structure”, restart the smart client and event server, and the plugin is running inside the smart client when it starting.
Is it possible to fetch IP-Addresses from my type of plugin or is it only available in integration/protocol types?
I tried to rewrite my code using the exact code inside the Playback example. Before i got the message that should return the IP, but the data part were null.
Now i get an error saying that the server actively rejected my communication.
//My code atm after rewriting some stuff to match Playback example a bit better.
private void ThisIsTriggeredByAButton(...)
{
ItemPickerForm picker = new ItemPickerForm();
picker.Text = "Select Camera";
picker.TopMost = true;
picker.KindFilter = Kind.Camera;
picker.Init(Configuration.Instance.GetItems());
if (picker.ShowDialog() == DialogResult.OK)
{
SelectedCamera = picker.SelectedItem;
_mc.TransmitMessage(new VideoOS.Platform.Messaging.Message(VideoOS.Platform.Messaging.MessageId.Server.GetIPAddressRequest, SelectedCamera.FQID), null, null, null);
}
}
private void RegisterCommunicationFilterIP() //I Trigger this in constructor
{
MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId);
_mc = MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId);
_mc.RegisterCommunicationFilter(IPAddressResponseHandler, new CommunicationIdFilter(MessageId.Server.GetIPAddressResponse));
}
private object IPAddressResponseHandler(VideoOS.Platform.Messaging.Message message, FQID destination, FQID sender)
{
string ip = (string)message.Data; //null check maybe?
MessageBox.Show(ip, SelectedCamera.Name);
return null;
}
To add, sending other messages/commands like this works:
EnvironmentManager.Instance.SendMessage(
new VideoOS.Platform.Messaging.Message(
MessageId.SmartClient.ApplicationControlCommand)
{
Data = ApplicationControlCommandData.Minimize
});
Ive heard something in line with that my type of plugin cannot fetch the IP-Address this way. Is that true or false?..
How does a breakpoint help when i already told you that the message to IPAddressResponseHandler is not null, but the message.data is null where the IP-Address should reside?
Forgive me if I’m misreading your sample code here as I’m on mobile, but I see you sending two messages - one of them is the correct message - a GetIPAddressRequest. But shortly after, you send your own GetIPAddressResponse message which I don’t think is your intention?
Later, you register a receiver for the GetIPAddressRequest message when what you want is to register a receiver for the GetIPAddressResponse message - and you want to register a receiver for that message before you send the request.
I suspect you’re actually catching your own message - I’ve done that to myself before.
I realize you’ve probably already read this part of the manual - I’m just posting a screenshot of it here for the benefit of others. What we need to do is register a receiver for the “response” message ID, and then send a message using the “request” message ID.
A null Message.Data value suggests to me that the software was unable to translate the FQID to an IP address (camera not found by FQID) which would be unusual, or more likely that somewhere you’re accidentally sending that message with null data to yourself but expecting it to be the message from the server.
I added a random string to the data tag in the message i were sending towards the server. And the message i caught had the same tag. So yes, im catching my own messages.
But still, i rewrote my code in almost every possible way, resulting in that i either catch my own message or there is no message to catch.
The sender/destination FQID when i send a message is not set, seen example with those not set. Do i need to make a change here? Or what am i doing wrong?
Tried both SendMessage() and PostMessage(), similar result.
I have the same issue if I try to use EnvironmentManager. I’m not sure if it’s expected to work through EnvironmentManager within Smart Client - I tend to still get a little confused about when I should use MessageCommunicationManager vs EnvironmentManager.
Here’s a sample I just tested where I’m using MessageCommunicationManager instead:
MessageCommunicationManager.Start(EnvironmentManager.Instance.MasterSite.ServerId);
var mc = MessageCommunicationManager.Get(EnvironmentManager.Instance.MasterSite.ServerId);
var obj = mc.RegisterCommunicationFilter(GetIpAddressResponseHandler,
new CommunicationIdFilter(MessageId.Server.GetIPAddressResponse));
foreach (var camera in EnumerateCameras())
{
mc.TransmitMessage(new Message(MessageId.Server.GetIPAddressRequest, camera.FQID), null, null, null );
}
Console.WriteLine("Press any key to continue. . .");
Console.ReadKey();
mc.UnRegisterCommunicationFilter(obj);
mc.Dispose();
MessageCommunicationManager.Stop(EnvironmentManager.Instance.MasterSite.ServerId);
And here’s my response handler
private static object GetIpAddressResponseHandler(Message message, FQID destination, FQID sender)
{
var camera = Configuration.Instance.GetItem(message.RelatedFQID);
if (camera != null)
{
Console.WriteLine($"{camera.Name}: {message.Data}");
}
return null;
}
And not that you need it, but here’s how I’m enumerating cameras
private static IEnumerable<Item> EnumerateCameras()
{
var stack = new Stack<Item>(Configuration.Instance.GetItemsByKind(Kind.Camera));
while (stack.Count > 0)
{
var item = stack.Pop();
if (item.FQID.FolderType != FolderType.No && item.HasChildren != HasChildren.No)
{
item.GetChildren().ForEach(stack.Push);
}
if (item.FQID.Kind == Kind.Camera)
{
yield return item;
}
}
}
Thats some really nice code. Sadly, i run into a problem i have had before.
When doing the mc.TransmitMessage(), it crashes.
“Unable to Transmit”…, Coult not connect to net.tcp://127.0.0.1:22333/CommunicationService.
TCP error code 10061.
So the code should work, so i dug into the other problem:
Started service: NetTcpPortSharing
In Windows features on/off, i turned on:
WCF HTTP Activation
WCF Non-HTTP Activation
And some more (added all in the .net tabs..)
Firewall off.
Still same error msg.
Im currently working towards a husky, i know some other developer have had hands on it before. Is there maybe some setting that can be set to create this problem? I did recognized that the 2 networks 192.168.10.0/25 and 192.168.10.128/25 were both sitting on 192.168.10.0/24 for some reason, so maybe there is more random changes…
It sounds like you’re unable to each the Event Server. It could be a number of things including
Event server is not running
Event server’s registered service URI cannot be resolved
Resolved hostname cannot be reached due to firewall
Something else
Does the Alarm List in Smart Client work? Or do you see your server with a red icon there? You should be able to create an alarm in management client, trigger it, and see new alarms in smart client, or change the alarm list properties in Smart Client to show events instead of alarms at which point you should see motion started/stopped events and other events posted in the alarm list.
At this point, you should open a support case with our tech support to identify why you’re unable to reach the event server as you’re no longer just dealing with MIP SDK. I imagine the support folks can get you squared away fairly quickly so that you can start getting these IP responses and continue with your development.