internal void UnBind(RdmRouteBinding binding) { if (running) { socket.UnBind(binding.Transport.Socket); } }
/// <summary> /// Gets the transport binding for a specific device. /// </summary> /// <remarks> /// Each device will have a transport binding which determines the transport used to comunicate with that device. /// </remarks> /// <param name="targetId">The ID of the device we wish to get the binding for.</param> /// <returns>The transport binding for the specified device.</returns> public RdmRouteBinding GetBindingForDevice(UId targetId) { if (targetId == UId.Broadcast) { throw new InvalidOperationException("Target device UId can not be broadcast."); } RdmRouteBinding route = GetTransportsRoutes(targetId).FirstOrDefault(); return(route); }
void Transport_NewDeviceFound(object sender, DeviceFoundEventArgs e) { RdmRouteBinding binding = Transports.FirstOrDefault <RdmRouteBinding>(item => item.Transport == sender); if (binding != null) { RegisterDevice(e.Id, binding); } RaiseNewDeviceFound(e); }
internal void UnBind(RdmRouteBinding binding) { if (running) { foreach (IRdmSocket transportSocket in binding.Transport.Sockets) { foreach (var socket in sockets) { socket.UnBind(transportSocket); } } } }
protected void RegisterDevice(UId deviceId, RdmRouteBinding transport) { lock (deviceTable) { RdmRouteBinding existingTransport; if (deviceTable.TryGetValue(deviceId, out existingTransport)) { //Already registered. if (existingTransport == transport) { return; } //Only register transports with a higher priority. if (existingTransport.Priority >= transport.Priority) { return; } } //Register device in device table. deviceTable[deviceId] = transport; } }
public void RegisterTransport(RdmRouteBinding routeDescription) { if (running) { throw new InvalidOperationException("The router is already running. You can not register a transport while the router is running. You must Stop it first."); } if (transports.ContainsKey(routeDescription.Priority)) { throw new InvalidOperationException("A transport with the priority {0} already exists. Each transport must have a unique priority."); } if (transports.Values.Any <RdmRouteBinding>(item => item.Transport == routeDescription.Transport)) { throw new InvalidOperationException("This transport has already been registered. You may only register a transport once."); } routeDescription.Transport.NewDeviceFound += new EventHandler <DeviceFoundEventArgs>(Transport_NewDeviceFound); lock (transports) { transports.Add(routeDescription.Priority, routeDescription); } }