Skip to content

Commit 5a8b8e1

Browse files
committed
refactor(extOSC): update some code, removed obsolete methods
1 parent 123e2be commit 5a8b8e1

3 files changed

Lines changed: 19 additions & 17 deletions

File tree

Assets/extOSC/Scripts/Core/OSCBase.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* Copyright (c) 2021 dr. ext (Vladimir Sigalkin) */
22

3+
using System;
4+
35
using UnityEngine;
46
using UnityEngine.Serialization;
57

@@ -25,12 +27,6 @@ public OSCMapBundle MapBundle
2527
set => _mapBundle = value;
2628
}
2729

28-
public bool WorkInEditor
29-
{
30-
get => _workInEditor;
31-
set => _workInEditor = value;
32-
}
33-
3430
public bool CloseOnPause
3531
{
3632
get => _closeOnPause;
@@ -39,6 +35,13 @@ public bool CloseOnPause
3935

4036
public abstract bool IsStarted { get; }
4137

38+
[Obsolete]
39+
public bool WorkInEditor
40+
{
41+
get => _workInEditor;
42+
set => _workInEditor = value;
43+
}
44+
4245
#endregion
4346

4447
#region Private Vars

Assets/extOSC/Scripts/OSCReceiver.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public OSCLocalHostMode LocalHostMode
4040

4141
public string LocalHost
4242
{
43-
get => RequestLocalHost();
43+
get => GetLocalHost();
4444
set
4545
{
4646
if (_localHost == value)
@@ -172,12 +172,12 @@ protected void OnValidate()
172172

173173
public override string ToString()
174174
{
175-
return $"<{GetType().Name} (LocalHost: {_localHost} LocalPort: {_localPort})>";
175+
return $"<{nameof(OSCReceiver)} (LocalHost: {_localHost} LocalPort: {_localPort})>";
176176
}
177177

178178
public override void Connect()
179179
{
180-
_receiverBackend.Connect(RequestLocalHost(), _localPort);
180+
_receiverBackend.Connect(GetLocalHost(), _localPort);
181181
}
182182

183183
public override void Close()
@@ -363,8 +363,7 @@ private void PacketReceived(IOSCPacket packet)
363363
}
364364
}
365365

366-
367-
private string RequestLocalHost()
366+
private string GetLocalHost()
368367
{
369368
return _localHostMode == OSCLocalHostMode.Any ? "0.0.0.0" : _localHost;
370369
}

Assets/extOSC/Scripts/OSCTransmitter.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public OSCReceiver SourceReceiver
6262

6363
public string LocalHost
6464
{
65-
get => RequestLocalHost();
65+
get => GetLocalHost();
6666
set
6767
{
6868
if (_localHost == value)
@@ -76,7 +76,7 @@ public string LocalHost
7676

7777
public int LocalPort
7878
{
79-
get => RequestLocalPort();
79+
get => GetLocalPort();
8080
set
8181
{
8282
if (_localPort == value)
@@ -217,7 +217,7 @@ protected void OnValidate()
217217

218218
public override void Connect()
219219
{
220-
_transmitterBackend.Connect(RequestLocalHost(), RequestLocalPort());
220+
_transmitterBackend.Connect(GetLocalHost(), GetLocalPort());
221221
_transmitterBackend.RefreshRemote(_remoteHost, _remotePort);
222222
}
223223

@@ -229,7 +229,7 @@ public override void Close()
229229

230230
public override string ToString()
231231
{
232-
return $"<{GetType().Name} (LocalHost: {_localHost} LocalPort: {_localPort} | RemoteHost: {_remoteHost}, RemotePort: {_remotePort})>";
232+
return $"<{nameof(OSCTransmitter)} (LocalHost: {_localHost} LocalPort: {_localPort} | RemoteHost: {_remoteHost}, RemotePort: {_remotePort})>";
233233
}
234234

235235
public void Send(IOSCPacket packet, OSCSendOptions options = OSCSendOptions.None)
@@ -278,7 +278,7 @@ private void RemoteRefresh()
278278
_transmitterBackend.RefreshRemote(_remoteHost, _remotePort);
279279
}
280280

281-
private string RequestLocalHost()
281+
private string GetLocalHost()
282282
{
283283
if (_localReceiver != null)
284284
return _localReceiver.LocalHost;
@@ -289,7 +289,7 @@ private string RequestLocalHost()
289289
return _localHost;
290290
}
291291

292-
private int RequestLocalPort()
292+
private int GetLocalPort()
293293
{
294294
if (_localReceiver != null)
295295
return _localReceiver.LocalPort;

0 commit comments

Comments
 (0)