public void Stop() { if (reliableSocket != null) { reliableSocket.Dispose(); reliableSocket = null; } if (slpUser != null) { slpUser.Dispose(); slpUser = null; } #if mDNS_Discovery if (dnsSD != null) { dnsSD.Dispose(); dnsSD = null; } #endif if (rdmNetSocket != null) { rdmNetSocket.Close(); rdmNetSocket = null; } }
public void Start() { if (acnSocket == null || !acnSocket.PortOpen) { acnSocket = new RdmNetSocket(UId.NewUId(0xFF), Guid.NewGuid(), "RDM Snoop"); acnSocket.NewRdmPacket += acnSocket_NewRdmPacket; acnSocket.Open(new IPEndPoint(LocalAdapter, 0)); } #if SLP_Discovery slpUser = new SlpUserAgent("ACN-DEFAULT"); slpUser.NetworkAdapter = localAdapter; slpUser.ServiceFound += new EventHandler <ServiceFoundEventArgs>(slpUser_ServiceFound); slpUser.Open(); slpUser.Find("service:rdmnet-device"); #endif #if mDNS_Discovery dnsSD = new ServiceBrowser(); dnsSD.ServiceAdded += dnsSD_ServiceAdded; dnsSD.Browse("_rdmnet._udp", "local"); #endif }
public void Stop() { if (dnsSD != null) { dnsSD.Dispose(); dnsSD = null; } if (slpUser != null) { slpUser.Close(); slpUser = null; } if (acnSocket != null) { acnSocket.Close(); acnSocket = null; } if (reliableSocket != null) { reliableSocket.Dispose(); reliableSocket = null; } }
/// <summary> /// Requests the attributes for a device. /// </summary> /// <param name="device">The device.</param> private void RequestAttributes(SlpDeviceInformation device) { if (FetchAttributes && device.DiscoveryAgents.Count > 0) { SlpUserAgent agent = device.DiscoveryAgents.First(); int requestId = agent.RequestAttributes(device.Endpoint, device.Url); lock (attributeRequestLog) { attributeRequestLog[new UserAgentRequest(agent, requestId)] = device; } } }
public void SplitAttributeListTest() { string attributeList = "(Foo=Bar),(Time=Money),(Knowledge=Power),(Tea=Happiness)"; Dictionary <string, string> expected = new Dictionary <string, string>(); expected["Foo"] = "Bar"; expected["Time"] = "Money"; expected["Knowledge"] = "Power"; expected["Tea"] = "Happiness"; Dictionary <string, string> actual; actual = SlpUserAgent.SplitAttributeList(attributeList); CollectionAssert.AreEquivalent(expected, actual, "Dictionarys didn't match"); }
/// <summary> /// Creates the SLP user agents. /// We need one for each network adaptor /// </summary> private void CreateAgents() { lock (devicesLock) { lock (attributeRequestLog) { lock (agents) { // If we have any agents get rid of them foreach (SlpUserAgent agent in agents.Keys) { agent.ServiceFound -= agent_ServiceFound; agent.AttributeReply -= agent_AttributeReply; agent.Dispose(); } agents.Clear(); // We also need to clear them from the devices foreach (SlpDeviceInformation device in devices.Values) { device.DiscoveryAgents.Clear(); } // Now create a new agent for each adaptor foreach (var localAddress in GetAllIpAddresses()) { SlpUserAgent agent = new SlpUserAgent(); agent.NetworkAdapter = localAddress; agent.Scope = Scope; agent.ServiceFound += agent_ServiceFound; agent.AttributeReply += agent_AttributeReply; agents.Add(agent, 0); } } } } }
/// <summary> /// Initializes a new instance of the <see cref="UserAgentRequest"/> struct. /// </summary> /// <param name="agent">The agent.</param> /// <param name="request">The request.</param> public UserAgentRequest(SlpUserAgent agent, int request) { Agent = agent; RequestId = request; }