Skip to content

Commit

Permalink
refactor(extOSC): update some code, removed obsolete methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Iam1337 committed Jul 22, 2021
1 parent 123e2be commit 5a8b8e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
15 changes: 9 additions & 6 deletions Assets/extOSC/Scripts/Core/OSCBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* Copyright (c) 2021 dr. ext (Vladimir Sigalkin) */

using System;

using UnityEngine;
using UnityEngine.Serialization;

Expand All @@ -25,12 +27,6 @@ public OSCMapBundle MapBundle
set => _mapBundle = value;
}

public bool WorkInEditor
{
get => _workInEditor;
set => _workInEditor = value;
}

public bool CloseOnPause
{
get => _closeOnPause;
Expand All @@ -39,6 +35,13 @@ public bool CloseOnPause

public abstract bool IsStarted { get; }

[Obsolete]
public bool WorkInEditor
{
get => _workInEditor;
set => _workInEditor = value;
}

#endregion

#region Private Vars
Expand Down
9 changes: 4 additions & 5 deletions Assets/extOSC/Scripts/OSCReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public OSCLocalHostMode LocalHostMode

public string LocalHost
{
get => RequestLocalHost();
get => GetLocalHost();
set
{
if (_localHost == value)
Expand Down Expand Up @@ -172,12 +172,12 @@ protected void OnValidate()

public override string ToString()
{
return $"<{GetType().Name} (LocalHost: {_localHost} LocalPort: {_localPort})>";
return $"<{nameof(OSCReceiver)} (LocalHost: {_localHost} LocalPort: {_localPort})>";
}

public override void Connect()
{
_receiverBackend.Connect(RequestLocalHost(), _localPort);
_receiverBackend.Connect(GetLocalHost(), _localPort);
}

public override void Close()
Expand Down Expand Up @@ -363,8 +363,7 @@ private void PacketReceived(IOSCPacket packet)
}
}


private string RequestLocalHost()
private string GetLocalHost()
{
return _localHostMode == OSCLocalHostMode.Any ? "0.0.0.0" : _localHost;
}
Expand Down
12 changes: 6 additions & 6 deletions Assets/extOSC/Scripts/OSCTransmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public OSCReceiver SourceReceiver

public string LocalHost
{
get => RequestLocalHost();
get => GetLocalHost();
set
{
if (_localHost == value)
Expand All @@ -76,7 +76,7 @@ public string LocalHost

public int LocalPort
{
get => RequestLocalPort();
get => GetLocalPort();
set
{
if (_localPort == value)
Expand Down Expand Up @@ -217,7 +217,7 @@ protected void OnValidate()

public override void Connect()
{
_transmitterBackend.Connect(RequestLocalHost(), RequestLocalPort());
_transmitterBackend.Connect(GetLocalHost(), GetLocalPort());
_transmitterBackend.RefreshRemote(_remoteHost, _remotePort);
}

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

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

public void Send(IOSCPacket packet, OSCSendOptions options = OSCSendOptions.None)
Expand Down Expand Up @@ -278,7 +278,7 @@ private void RemoteRefresh()
_transmitterBackend.RefreshRemote(_remoteHost, _remotePort);
}

private string RequestLocalHost()
private string GetLocalHost()
{
if (_localReceiver != null)
return _localReceiver.LocalHost;
Expand All @@ -289,7 +289,7 @@ private string RequestLocalHost()
return _localHost;
}

private int RequestLocalPort()
private int GetLocalPort()
{
if (_localReceiver != null)
return _localReceiver.LocalPort;
Expand Down

0 comments on commit 5a8b8e1

Please sign in to comment.