@@ -11,7 +11,7 @@ namespace VRCFTPicoModule;
1111public class VRCFTPicoModule : ExtTrackingModule
1212{
1313 private static readonly int [ ] Ports = [ 29765 , 29763 ] ;
14- private static readonly UdpClient [ ] Clients = Ports . Select ( port => new UdpClient ( port ) { Client = { ReceiveTimeout = 100 } } ) . ToArray ( ) ;
14+ private UdpClient [ ] _clients = [ ] ;
1515 private static UdpClient _udpClient = new ( ) ;
1616 private static int _port ;
1717 private Updater ? _updater ;
@@ -108,7 +108,7 @@ private void UpdateModuleInfo((bool, bool) initializationResult)
108108 { Item1 : false , Item2 : true } => T ( "expression-tracking" ) ,
109109 _ => ""
110110 } ;
111- ModuleInformation . Name = "PICO / " + moduleTrackingStatus + moduleProtocol ;
111+ ModuleInformation . Name = "VRCFTPicoModule (modified) / " + moduleTrackingStatus + moduleProtocol ;
112112 var stream = GetType ( ) . Assembly . GetManifestResourceStream ( "VRCFTPicoModule.Assets.pico.png" ) ;
113113 ModuleInformation . StaticImages = stream != null ? [ stream ] : ModuleInformation . StaticImages ;
114114 }
@@ -117,7 +117,12 @@ private async Task<int> ListenOnPorts()
117117 {
118118 try
119119 {
120- var tasks = Clients . Select ( client => client . ReceiveAsync ( ) ) . ToArray ( ) ;
120+ _clients = Ports . Select ( port => new UdpClient ( port )
121+ {
122+ Client = { ReceiveTimeout = 100 }
123+ } ) . ToArray ( ) ;
124+
125+ var tasks = _clients . Select ( client => client . ReceiveAsync ( ) ) . ToArray ( ) ;
121126
122127 if ( tasks . Length == 0 )
123128 {
@@ -126,7 +131,7 @@ private async Task<int> ListenOnPorts()
126131
127132 var completedTask = await Task . WhenAny ( tasks ) ;
128133
129- foreach ( var client in Clients ) client . Dispose ( ) ;
134+ foreach ( var client in _clients ) client . Dispose ( ) ;
130135
131136 return Array . IndexOf ( tasks , completedTask ) ;
132137 }
@@ -143,7 +148,7 @@ public override void Update()
143148 if ( _shuttingDown ) return ;
144149
145150 try
146- {
151+ {
147152 _updater ? . Update ( Status ) ;
148153 }
149154 catch ( AggregateException ex ) when ( ex . InnerException is ObjectDisposedException ) { }
@@ -154,7 +159,7 @@ public override void Teardown()
154159 {
155160 _shuttingDown = true ;
156161
157- foreach ( var client in Clients )
162+ foreach ( var client in _clients )
158163 client . Dispose ( ) ;
159164 _udpClient . Dispose ( ) ;
160165 }
@@ -164,7 +169,7 @@ private void LoadEyeGain()
164169 {
165170 if ( ! File . Exists ( GainFilePath ) )
166171 {
167- Logger . LogDebug ( "eye_gain.txt not found, using default values" ) ;
172+ Logger . LogInformation ( T ( "eye-gain- not- found" ) ) ;
168173 return ;
169174 }
170175
@@ -178,16 +183,16 @@ private void LoadEyeGain()
178183 _eyeGainX = x ;
179184 _eyeGainY = y ;
180185
181- Logger . LogInformation ( $ "Eye gain loaded: X= { _eyeGainX } , Y= { _eyeGainY } " ) ;
186+ Logger . LogInformation ( T ( "eye- gain- loaded" ) , _eyeGainX , _eyeGainY ) ;
182187 }
183188 else
184189 {
185- Logger . LogWarning ( $ "Invalid eye_gain.txt format: \" { text } \" " ) ;
190+ Logger . LogWarning ( T ( "eye-gain-invalid" ) , text ) ;
186191 }
187192 }
188193 catch ( Exception ex )
189194 {
190- Logger . LogError ( ex , "Failed to read eye_gain.txt" ) ;
195+ Logger . LogError ( ex , T ( "eye-gain-failed" ) ) ;
191196 }
192197 }
193198}
0 commit comments