diff --git a/Components/Network/ART-NET/ARTNETCLIENT.cs b/Components/Network/ART-NET/ARTNETCLIENT.cs deleted file mode 100644 index 91677ad..0000000 --- a/Components/Network/ART-NET/ARTNETCLIENT.cs +++ /dev/null @@ -1,152 +0,0 @@ -using System; -using System.Net; -using System.Net.Sockets; -using System.Threading.Tasks; -using Elements.Core; -using FrooxEngine; - -namespace Obsidian -{ - - [Category(new string[] { "Obsidian/Network/ArtNet" })] - public class ArtNetClient : Component - { - public readonly Sync URL; - public readonly UserRef HandlingUser; - public readonly Sync AccessReason; - public readonly Sync ConnectRetryInterval; - public readonly Sync IsConnected; - - private Uri _currentURL; - private UdpClient _udpClient; - - public event Action Connected; - public event Action Closed; - public event Action Error; - public event Action PacketReceived; // For ArtNet packets - public event Action DMXDataReceived; // For DMX512 data - - protected override void OnAwake() - { - ConnectRetryInterval.Value = 10f; - } - - protected override void OnChanges() - { - Uri uri = (Enabled ? URL.Value : null); - if (HandlingUser.Target != LocalUser) - { - uri = null; - } - - if (uri != _currentURL) - { - _currentURL = uri; - CloseCurrent(); - IsConnected.Value = false; - if (_currentURL != null) - { - StartTask(async delegate - { - await ConnectTo(_currentURL); - }); - } - } - } - - private async Task ConnectTo(Uri target) - { - if (target.Scheme != "artnet") - { - Error?.Invoke(this, "Invalid URL scheme. Expected 'artnet://'."); - return; - } - - if (await Engine.Security.RequestAccessPermission(target.Host, target.Port, AccessReason.Value ?? "ArtNet Client") == HostAccessPermission.Allowed && !(target != _currentURL) && !IsRemoved) - { - _udpClient = new UdpClient(target.Port); - IsConnected.Value = true; - Connected?.Invoke(this); - StartTask(ReceiveLoop); - } - } - - private async Task ReceiveLoop() - { - var remoteEndPoint = new IPEndPoint(IPAddress.Any, 0); - while (IsConnected.Value && _udpClient != null) - { - try - { - UdpReceiveResult result = await _udpClient.ReceiveAsync(); - byte[] receivedData = result.Buffer; - - // Check if the data is an ArtNet packet or DMX512 data - if (IsArtNetPacket(receivedData)) - { - PacketReceived?.Invoke(this, receivedData); - } - else - { - DMXDataReceived?.Invoke(this, receivedData); - } - } - catch (Exception ex) - { - Error?.Invoke(this, ex.Message); - break; - } - } - } - - private bool IsArtNetPacket(byte[] data) - { - // Art-Net packets start with the ASCII sequence for "Art-Net" followed by a null byte. - byte[] artNetHeader = new byte[] { 65, 114, 116, 45, 78, 101, 116, 0 }; - - if (data.Length < artNetHeader.Length) - { - return false; - } - - for (int i = 0; i < artNetHeader.Length; i++) - { - if (data[i] != artNetHeader[i]) - { - return false; - } - } - - return true; - } - - protected override void OnDispose() - { - CloseCurrent(); - base.OnDispose(); - } - - private void CloseCurrent() - { - if (_udpClient != null) - { - UdpClient udpClient = _udpClient; - _udpClient = null; - try - { - Closed?.Invoke(this); - } - catch (Exception ex) - { - UniLog.Error("Exception in running Closed event on ArtNetClient:\n" + ex); - } - udpClient.Close(); - } - } - - public static implicit operator ArtNetClient(ProtoFlux.Runtimes.Execution.Nodes.FrooxEngine.Network.WebsocketConnect v) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/ProjectObsidian.csproj b/ProjectObsidian.csproj index 7def3c4..49fecf8 100644 --- a/ProjectObsidian.csproj +++ b/ProjectObsidian.csproj @@ -12,7 +12,6 @@ C:\Program Files (x86)\Steam\steamapps\common\Resonite\ $(HOME)/.steam/steam/steamapps/common/Resonite/ /mnt/LocalDisk2/SteamLibrary/steamapps/common/Resonite/ - G:\SteamLibrary\steamapps\common\Resonite\ @@ -42,7 +41,4 @@ $(ResonitePath)Resonite_Data/Managed/Elements.Assets.dll - - - diff --git a/ProtoFlux/Bindings/Network/Art-Net/ArtNetConnectNode.cs b/ProtoFlux/Bindings/Network/Art-Net/ArtNetConnectNode.cs deleted file mode 100644 index 3ee84d1..0000000 --- a/ProtoFlux/Bindings/Network/Art-Net/ArtNetConnectNode.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using FrooxEngine; -using FrooxEngine.ProtoFlux; -using ProtoFlux.Core; -using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Network.ArtNet; -using Obsidian; - -[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Network/ArtNet" })] -public class ArtNetClientConnectNode : FrooxEngine.ProtoFlux.Runtimes.Execution.ActionBreakableFlowNode -{ - public readonly SyncRef> Client; - public readonly SyncRef> URL; - public readonly SyncRef> HandlingUser; - - public override Type NodeType => typeof(ArtNetClientConnect); - - public ArtNetClientConnect TypedNodeInstance { get; private set; } - - public override INode NodeInstance => TypedNodeInstance; - - public override int NodeInputCount => 3; - - public override N Instantiate() - { - if (TypedNodeInstance != null) - { - throw new InvalidOperationException("Node has already been instantiated"); - } - TypedNodeInstance = new ArtNetClientConnect(); - return TypedNodeInstance as N; - } - - protected override void AssociateInstanceInternal(INode node) - { - TypedNodeInstance = node as ArtNetClientConnect ?? throw new ArgumentException("Node instance is not of type ArtNetClientConnect"); - } - - public override void ClearInstance() - { - TypedNodeInstance = null; - } - - protected override ISyncRef GetInputInternal(ref int index) - { - switch (index) - { - case 0: return Client; - case 1: return URL; - case 2: return HandlingUser; - default: index -= 3; return null; - } - } -} diff --git a/ProtoFlux/Network/Art-Net/ArtNetConnect.cs b/ProtoFlux/Network/Art-Net/ArtNetConnect.cs deleted file mode 100644 index dfa3e61..0000000 --- a/ProtoFlux/Network/Art-Net/ArtNetConnect.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using FrooxEngine; -using FrooxEngine.ProtoFlux; -using Obsidian; -using ProtoFlux.Core; -using ProtoFlux.Runtimes.Execution; - -[NodeCategory("Obsidian/Network/Websockets")] -public class ArtNetConnect : ActionBreakableFlowNode -{ - public ObjectInput Client; - - public ObjectInput URL; - - public ObjectInput HandlingUser; - - protected override bool Do(FrooxEngineContext context) - { - ArtNetClient ArtnetClient = Client.Evaluate(context); - if (ArtnetClient == null) - { - return false; - } - Uri uri = URL.Evaluate(context); - if (uri != null) - { - ArtnetClient.URL.Value = uri; - } - ArtnetClient.HandlingUser.Target = HandlingUser.Evaluate(context, context.LocalUser); - return true; - } -}