@@ -54,7 +54,7 @@ public class OscPosition(Vector3 position = default, Quaternion orientation = de
5454[ ExportMetadata ( "Name" , "VRChat OSC" ) ]
5555[ ExportMetadata ( "Guid" , "K2VRTEAM-AME2-APII-SNDP-SENDPTVRCOSC" ) ]
5656[ ExportMetadata ( "Publisher" , "K2VR Team" ) ]
57- [ ExportMetadata ( "Version" , "1.0.0.0 " ) ]
57+ [ ExportMetadata ( "Version" , "1.0.0.1 " ) ]
5858[ ExportMetadata ( "Website" , "https://github.com/KinectToVR/plugin_OSC" ) ]
5959[ ExportMetadata ( "DependencyLink" , "https://docs.k2vr.tech/{0}/osc/" ) ]
6060[ ExportMetadata ( "CoreSetupData" , typeof ( SetupData ) ) ]
@@ -234,7 +234,8 @@ public int Initialize()
234234 var services = _oscQueryService . GetOSCQueryServices ( ) ;
235235
236236 // Trigger event for any existing OSCQueryServices
237- foreach ( var profile in services ) OnOscQueryServiceFound ( profile ) ;
237+ foreach ( var profile in services . Where ( x => x . name is not AmethystOscServiceName ) )
238+ OnOscQueryServiceFound ( profile ) ;
238239
239240 // Query network for services
240241 _oscQuery . RefreshServices ( ) ;
@@ -479,38 +480,46 @@ public TrackerBase GetTrackerPose(string contains, bool canBeFromAmethyst = true
479480
480481 private async void OnOscQueryServiceFound ( OSCQueryServiceProfile profile )
481482 {
482- Host ? . Log ( $ "Found service { profile . name } at { profile . address } !") ;
483- if ( ! await ServiceSupportsTracking ( profile ) ) return ;
484-
485- var hostInfo = await GetHostInfo ( profile . address , profile . port ) ;
486- if ( _receivers . TryGetValue ( profile . name , out var value ) &&
487- value . Destination . Address . Equals ( profile . address ) &&
488- value . Destination . Port == hostInfo . oscPort )
483+ try
489484 {
490- Host ? . Log ( $ "Service with key \" { profile . name } \" at " +
491- $ "{ profile . address } :{ hostInfo . oscPort } already registered, skipping") ;
492- return ;
493- }
485+ Host ? . Log ( $ "Found service { profile . name } at { profile . address } !") ;
486+ if ( ! await ServiceSupportsTracking ( profile ) ) return ;
494487
495- AddTrackingReceiver ( profile . name , profile . address , hostInfo . oscPort ) ;
488+ var hostInfo = await GetHostInfo ( profile . address , profile . port ) ;
489+ if ( _receivers . TryGetValue ( profile . name , out var value ) &&
490+ value . Destination . Address . Equals ( profile . address ) &&
491+ value . Destination . Port == hostInfo . oscPort )
492+ {
493+ Host ? . Log ( $ "Service with key \" { profile . name } \" at " +
494+ $ "{ profile . address } :{ hostInfo . oscPort } already registered, skipping") ;
495+ return ;
496+ }
496497
497- Host ? . Log ( $ "Set up { profile . name } at { profile . address } :{ hostInfo . oscPort } ") ;
498- ServiceStatus = ( int ) OscStatusEnum . Success ;
499- Host ? . RefreshStatusInterface ( ) ; // We're connected now!
500- return ; // That's all (assuming everything's okay.....)
498+ AddTrackingReceiver ( profile . name , profile . address , hostInfo . oscPort ) ;
501499
502- // Checks for compatibility by looking for matching Chatbox root node
503- async Task < bool > ServiceSupportsTracking ( OSCQueryServiceProfile profile )
504- {
505- var tree = await GetOSCTree ( profile . address , profile . port ) ;
506- return tree . GetNodeWithPath ( TRACKERS_ROOT ) != null ;
507- }
500+ Host ? . Log ( $ "Set up { profile . name } at { profile . address } :{ hostInfo . oscPort } ") ;
501+ ServiceStatus = ( int ) OscStatusEnum . Success ;
502+ Host ? . RefreshStatusInterface ( ) ; // We're connected now!
503+ return ; // That's all (assuming everything's okay.....)
508504
509- // Does the actual construction of the OSC Client
510- void AddTrackingReceiver ( string key , IPAddress address , int port )
505+ // Checks for compatibility by looking for matching Chatbox root node
506+ async Task < bool > ServiceSupportsTracking ( OSCQueryServiceProfile p )
507+ {
508+ var tree = await GetOSCTree ( p . address , p . port ) ;
509+ return tree . GetNodeWithPath ( TRACKERS_ROOT ) != null ;
510+ }
511+
512+ // Does the actual construction of the OSC Client
513+ void AddTrackingReceiver ( string key , IPAddress address , int port )
514+ {
515+ var receiver = new OscClientPlus ( address . ToString ( ) , port ) ;
516+ _receivers [ key ] = receiver ;
517+ }
518+ }
519+ catch ( Exception e )
511520 {
512- var receiver = new OscClientPlus ( address . ToString ( ) , port ) ;
513- _receivers [ key ] = receiver ;
521+ Host ? . Log ( $ "Couldn't set up service with key \" { profile . name } \" : { e . Message } " ) ;
522+ Host ? . Log ( e ) ;
514523 }
515524 }
516525
0 commit comments