@@ -239,7 +239,7 @@ public void Dispose()
239239 private readonly ConcurrentDictionary < string , RemoteClient > remoteClients = new ConcurrentDictionary < string , RemoteClient > ( ) ;
240240 private readonly ConcurrentDictionary < string , RemoteClient > remoteClientsTimeouted = new ConcurrentDictionary < string , RemoteClient > ( ) ;
241241 public IReadOnlyCollection < RemoteClient > RemoteClients { get ; private set ; } = new List < RemoteClient > ( ) ;
242- public IReadOnlyCollection < RemoteClientPort > RemoteClientsPorts { get { return remoteClients . SelectMany ( rc => rc . Value . Ports ) . ToList ( ) . AsReadOnly ( ) ; } }
242+ public IReadOnlyCollection < RemoteClientPort > RemoteClientsPorts { get { return remoteClients ? . Where ( rc => rc . Value ? . Ports != null ) . SelectMany ( rc => rc . Value . Ports ) . ToList ( ) . AsReadOnly ( ) ; } }
243243
244244 public event EventHandler < PortAddress > DMXReceived ;
245245 public event EventHandler SyncReceived ;
@@ -581,7 +581,7 @@ private async Task sendAllArtDMX()
581581
582582 try
583583 {
584- var ports = RemoteClientsPorts . Where ( port => port . OutputPortAddress . HasValue && ! port . Timouted ( ) ) . ToList ( ) ;
584+ var ports = RemoteClientsPorts ? . Where ( port => port . OutputPortAddress . HasValue && ! port . Timouted ( ) ) ? . ToList ( ) ;
585585
586586 int sended = 0 ;
587587 foreach ( var port in ports )
@@ -590,13 +590,23 @@ private async Task sendAllArtDMX()
590590 if ( sendDMXBuffer . TryGetValue ( port . OutputPortAddress . Value , out DMXSendBag bag ) )
591591 if ( ( bag . Updated && ( DateTime . UtcNow - bag . LastSended ) . TotalMilliseconds >= dmxRefreshTime ) || ( DateTime . UtcNow - bag . LastSended ) . TotalMilliseconds >= dmxKeepAliveTime )
592592 {
593- bag . LastSended = DateTime . UtcNow ;
594- PortConfig config = portConfigs . FirstOrDefault ( pc => PortAddress . Equals ( pc . PortAddress , port . OutputPortAddress ) ) ;
595- byte sourcePort = config ? . PortNumber ?? 0 ;
596- await sendArtDMX ( port , sourcePort , bag . Data , bag . GetSequence ( ) , config ? . ForceBroadcast ?? false ) ;
597- sended ++ ;
598- if ( config == null )
593+ PortConfig config = null ;
594+ byte sourcePort = 0 ;
595+ try
596+ {
597+ bag . LastSended = DateTime . UtcNow ;
598+ config = portConfigs ? . FirstOrDefault ( pc => PortAddress . Equals ( pc . PortAddress , port . OutputPortAddress ) ) ;
599+ sourcePort = config ? . PortNumber ?? 0 ;
600+ await sendArtDMX ( port , sourcePort , bag . Data , bag . GetSequence ( ) , config ? . ForceBroadcast ?? false ) ;
601+ sended ++ ;
602+ if ( config == null )
603+ return ;
604+ }
605+ catch ( Exception e )
606+ {
607+ Logger . LogError ( e , "Inner Block" ) ;
599608 return ;
609+ }
600610 foreach ( IPv4Address ip in config ? . AdditionalIPEndpoints )
601611 {
602612 await sendArtDMX ( ip , config . PortAddress , sourcePort , bag . Data , bag . GetSequence ( ) ) ;
@@ -605,7 +615,7 @@ private async Task sendAllArtDMX()
605615 bag . LastSended = DateTime . UtcNow ;
606616 }
607617 }
608- catch ( Exception e ) { Logger . LogError ( e ) ; }
618+ catch ( Exception e ) { Logger . LogError ( e , "Outer Block" ) ; }
609619 if ( EnableSync && sended != 0 )
610620 await sendArtSync ( ) ;
611621
0 commit comments