@@ -30,7 +30,7 @@ namespace plugin_Relay;
3030[ ExportMetadata ( "Name" , "Amethyst Tracking Relay" ) ]
3131[ ExportMetadata ( "Guid" , "K2VRTEAM-AME2-APII-DVCE-TRACKINGRELAY" ) ]
3232[ ExportMetadata ( "Publisher" , "K2VR Team" ) ]
33- [ ExportMetadata ( "Version" , "1.0.0.1 " ) ]
33+ [ ExportMetadata ( "Version" , "1.0.0.3 " ) ]
3434[ ExportMetadata ( "Website" , "https://github.com/KimihikoAkayasaki/plugin_Relay" ) ]
3535public class RelayService : IServiceEndpoint
3636{
@@ -167,10 +167,17 @@ public TrackerBase GetTrackerPose(string contains, bool canBeFromAmethyst = true
167167 public void Heartbeat ( )
168168 {
169169 if ( ServiceStatus != 0 || Host is null ) return ;
170- lock ( Host . UpdateThreadLock )
170+ try
171171 {
172- DevicesToUpdate . Select ( guid => _trackingDevices . GetValueOrDefault ( guid , null ) )
173- . Where ( x => x is not null ) . Where ( x => ! x . IsSelfUpdateEnabled ) . ToList ( ) . ForEach ( x => x . Update ( ) ) ;
172+ lock ( Host . UpdateThreadLock )
173+ {
174+ DevicesToUpdate . Select ( guid => _trackingDevices . GetValueOrDefault ( guid , null ) )
175+ . Where ( x => x is not null ) . Where ( x => ! x . IsSelfUpdateEnabled ) . ToList ( ) . ForEach ( x => x . Update ( ) ) ;
176+ }
177+ }
178+ catch ( Exception ex )
179+ {
180+ Host ? . Log ( ex ) ;
174181 }
175182 }
176183
@@ -455,7 +462,12 @@ public async Task<TrackingDevice> GetTrackingDevice(string guid, CancellationTok
455462 public async Task < List < TrackedJoint > > GetTrackedJoints ( string guid , CancellationToken cancellationToken = default )
456463 {
457464 if ( RelayService . Instance is null ) return null ;
458- RelayService . Instance . DevicesToUpdate . Add ( guid ) ; // Mark the device as used
465+ if ( ! RelayService . Instance . DevicesToUpdate . Contains ( guid ) )
466+ lock ( RelayService . Instance . Host . UpdateThreadLock )
467+ {
468+ RelayService . Instance . DevicesToUpdate . Add ( guid ) ; // Mark the device as used
469+ }
470+
459471 var device = RelayService . Instance . GetTrackingDevice ( guid ) ;
460472 return device . IsSkeletonTracked ? device . TrackedJoints . ToList ( ) : null ;
461473 }
0 commit comments