From 013e4779ecf9a4c617a244bc3e4196f4594b2916 Mon Sep 17 00:00:00 2001 From: paulinelvne Date: Fri, 10 Mar 2023 14:38:14 +0100 Subject: [PATCH] Remove Node Simulator --- Assets/Scenes/Main.unity | 207 +------- .../Scripts/AugmentaSimulation/NodeManager.cs | 58 --- .../AugmentaSimulation/NodeManager.cs.meta | 11 - .../Controllables/NodeManagerControllable.cs | 49 -- .../NodeManagerControllable.cs.meta | 11 - .../Controllables/OSCManagerControllable.cs | 7 - Assets/Scripts/Network/OSCManager.cs | 464 ------------------ Assets/Scripts/Network/ZeroconfManager.cs | 58 --- .../Scripts/Network/ZeroconfManager.cs.meta | 11 - 9 files changed, 11 insertions(+), 865 deletions(-) delete mode 100644 Assets/Scripts/AugmentaSimulation/NodeManager.cs delete mode 100644 Assets/Scripts/AugmentaSimulation/NodeManager.cs.meta delete mode 100644 Assets/Scripts/Controllables/NodeManagerControllable.cs delete mode 100644 Assets/Scripts/Controllables/NodeManagerControllable.cs.meta delete mode 100644 Assets/Scripts/Network/ZeroconfManager.cs delete mode 100644 Assets/Scripts/Network/ZeroconfManager.cs.meta diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index d213214..f947f49 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -241,11 +241,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a4c8e32f3cdcfe04caee8594416a7f5d, type: 3} m_Name: m_EditorClassIdentifier: - zeroconfManager: {fileID: 393421887} - yoVersion: 2 - yoPort: 36278 - connectionTimeout: 60 - debug: 0 --- !u!4 &18100216 Transform: m_ObjectHideFlags: 0 @@ -286,11 +281,8 @@ MonoBehaviour: closePanelAtStart: 0 currentPreset: presetList: [] - yoVersion: 0 - yoPort: 0 outputPort: 0 outputIP: - connectionTimeout: 0 --- !u!1 &33820299 GameObject: m_ObjectHideFlags: 0 @@ -429,38 +421,6 @@ LightingSettings: m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 m_PVRTiledBaking: 0 ---- !u!1 &135095402 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 135095403} - m_Layer: 0 - m_Name: NodeSimulation - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!4 &135095403 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 135095402} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 1396794540} - m_Father: {fileID: 0} - m_RootOrder: 6 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &183710613 GameObject: m_ObjectHideFlags: 0 @@ -682,7 +642,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1144076143} - m_RootOrder: 2 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &295429783 MonoBehaviour: @@ -877,50 +837,6 @@ MonoBehaviour: _senderName: AugmentaSimulator_VideoOutput _useCamera: 0 _alphaSupport: 0 ---- !u!1 &393421886 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 393421888} - - component: {fileID: 393421887} - m_Layer: 0 - m_Name: ZeroconfManager - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &393421887 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 393421886} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c81078e2b27379140a5eea674206f0a3, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!4 &393421888 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 393421886} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1144076143} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &436944970 GameObject: m_ObjectHideFlags: 0 @@ -2310,7 +2226,6 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 18100216} - - {fileID: 393421888} - {fileID: 295429782} - {fileID: 1386690176} m_Father: {fileID: 0} @@ -2386,7 +2301,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 8 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1311473798 GameObject: @@ -2709,7 +2624,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1144076143} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1386690177 MonoBehaviour: @@ -2737,13 +2652,14 @@ MonoBehaviour: currentPreset: presetList: [] preset: - TUIOPresets: [] - outputPort: 0 + outputScene: 0 + TUIOPort: 0 outputIP: dimension: - TUIODimensions: [] descriptor: TUIODescriptors: [] + TUIOPresets: [] + TUIODimensions: [] --- !u!114 &1386690178 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2756,111 +2672,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 18ab29c69390789419f51dac4891f431, type: 3} m_Name: m_EditorClassIdentifier: + descriptor: + preset: + dimension: sceneDepth: 10 - debug: 0 ---- !u!1 &1396794539 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1396794540} - - component: {fileID: 1396794542} - - component: {fileID: 1396794541} - m_Layer: 0 - m_Name: Manager - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1396794540 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1396794539} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 135095403} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1396794541 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1396794539} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8b933b1218ee8cb4aa798b43cfedb3ce, type: 3} - m_Name: - m_EditorClassIdentifier: - TargetScript: {fileID: 1396794542} - BarColor: {r: 1, g: 0, b: 0.9735141, a: 1} - id: NodeManager - folder: - debug: 0 - targetDirectory: - sourceScene: - usePanel: 1 - usePresets: 1 - hasPresets: 0 - closePanelAtStart: 0 - currentPreset: - presetList: [] - nodeName: - sensorType: - sensorBrand: - sensorName: - sensorHFOV: 0 - sensorVFOV: 0 - floorMode: - floorState: - backgroundMode: - debugPipeName: - debugSensor: - debugVideoPipe: - debugTrackingPipe: - debugPID: 0 - currentTags: - newTag: ---- !u!114 &1396794542 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1396794539} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d869660ca48de2e4195369bc69254c2c, type: 3} - m_Name: - m_EditorClassIdentifier: - zeroconfManager: {fileID: 393421887} - tagsList: - - room1 - - fountain - sensorType: DepthCamera - sensorBrand: Orbbec - sensorName: AstraPro - sensorHFOV: 60 - sensorVFOV: 49.5 - floorMode: Auto - floorState: Found - backgroundMode: Auto - debugPipeName: OrbbecAstra - debugSensor: OrbbecAstraPro - debugVideoPipe: DepthPipe - debugTrackingPipe: TrackingV1 - debugPID: 69 --- !u!1 &1554386833 GameObject: m_ObjectHideFlags: 0 @@ -3443,7 +3258,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2071885444 GameObject: diff --git a/Assets/Scripts/AugmentaSimulation/NodeManager.cs b/Assets/Scripts/AugmentaSimulation/NodeManager.cs deleted file mode 100644 index 2059926..0000000 --- a/Assets/Scripts/AugmentaSimulation/NodeManager.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - -public class NodeManager : MonoBehaviour -{ - public ZeroconfManager zeroconfManager; - - public string nodeName { - get { return _nodeName; } - set { _nodeName = value; UpdateName(); } - } - private string _nodeName = "node"; - - public List tagsList = new List(); - - public string sensorType = "DepthCamera"; - public string sensorBrand = "Orbbec"; - public string sensorName = "AstraPro"; - public float sensorHFOV = 60.0f; - public float sensorVFOV = 49.5f; - - public string floorMode = "Auto"; - public string floorState = "Found"; - public string backgroundMode = "Auto"; - - public string debugPipeName = "OrbbecAstra"; - public string debugSensor = "OrbbecAstraPro"; - public string debugVideoPipe = "DepthPipe"; - public string debugTrackingPipe = "TrackingV1"; - public int debugPID = 69; - - private int _defaultYoPort = 36278; - - private void Awake() { - - UpdateName(); - } - - void UpdateName() - { - zeroconfManager.Setup(_defaultYoPort, _nodeName, getZeroconfKeys()); - } - - Dictionary getZeroconfKeys() - { - Dictionary keys = new Dictionary(); - keys.Add("mac", NetworkManager.GetMacAddress()); - keys.Add("tags", string.Join(",", tagsList)); - return keys; - } - - public void UpdateTagsList() - { - zeroconfManager.Setup(_defaultYoPort, _nodeName, getZeroconfKeys()); - } -} diff --git a/Assets/Scripts/AugmentaSimulation/NodeManager.cs.meta b/Assets/Scripts/AugmentaSimulation/NodeManager.cs.meta deleted file mode 100644 index 33cee3c..0000000 --- a/Assets/Scripts/AugmentaSimulation/NodeManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d869660ca48de2e4195369bc69254c2c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Controllables/NodeManagerControllable.cs b/Assets/Scripts/Controllables/NodeManagerControllable.cs deleted file mode 100644 index 6171da6..0000000 --- a/Assets/Scripts/Controllables/NodeManagerControllable.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class NodeManagerControllable : Controllable -{ - [OSCProperty] public string nodeName; - - [OSCProperty] public string sensorType; - [OSCProperty] public string sensorBrand; - [OSCProperty] public string sensorName; - [OSCProperty] public float sensorHFOV; - [OSCProperty] public float sensorVFOV; - - [OSCProperty] public string floorMode; - [OSCProperty] public string floorState; - [OSCProperty] public string backgroundMode; - - [OSCProperty] public string debugPipeName; - [OSCProperty] public string debugSensor; - [OSCProperty] public string debugVideoPipe; - [OSCProperty] public string debugTrackingPipe; - [OSCProperty] public int debugPID; - - [OSCProperty(isInteractible = false)] - public string currentTags; - - [OSCProperty] public string newTag; - - [OSCMethod] - public void AddTag() { - - if ((TargetScript as NodeManager).tagsList.Contains(newTag)) - return; - - (TargetScript as NodeManager).tagsList.Add(newTag); - (TargetScript as NodeManager).UpdateTagsList(); - } - - [OSCMethod] - public void RemoveTag() { - - if (!(TargetScript as NodeManager).tagsList.Contains(newTag)) - return; - - (TargetScript as NodeManager).tagsList.Remove(newTag); - (TargetScript as NodeManager).UpdateTagsList(); - } -} diff --git a/Assets/Scripts/Controllables/NodeManagerControllable.cs.meta b/Assets/Scripts/Controllables/NodeManagerControllable.cs.meta deleted file mode 100644 index 548f6bd..0000000 --- a/Assets/Scripts/Controllables/NodeManagerControllable.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8b933b1218ee8cb4aa798b43cfedb3ce -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Controllables/OSCManagerControllable.cs b/Assets/Scripts/Controllables/OSCManagerControllable.cs index c7ff809..79b9314 100644 --- a/Assets/Scripts/Controllables/OSCManagerControllable.cs +++ b/Assets/Scripts/Controllables/OSCManagerControllable.cs @@ -4,16 +4,9 @@ public class OSCManagerControllable : Controllable { - [Header("YO VERSION")] - [OSCProperty(isInteractible = false)] public int yoVersion; - [OSCProperty(isInteractible = false)] public int yoPort; - [Header("OUTPUT SETTINGS")] [OSCProperty] public int outputPort; [OSCProperty] public string outputIP; - [OSCProperty] - [Tooltip("Time in s before a connection without heartbeat is deleted. 0 = Never.")] - public float connectionTimeout; } diff --git a/Assets/Scripts/Network/OSCManager.cs b/Assets/Scripts/Network/OSCManager.cs index 8bd5221..e7da86b 100644 --- a/Assets/Scripts/Network/OSCManager.cs +++ b/Assets/Scripts/Network/OSCManager.cs @@ -9,12 +9,6 @@ public class OSCManager : MonoBehaviour { public static OSCManager activeManager; - public ZeroconfManager zeroconfManager; - - [Header("Yo Version")] - public int yoVersion = 2; - public int yoPort = 36278; - [Header("Output settings")] private int _outputPort = 12000; public int outputPort { @@ -28,20 +22,9 @@ public string outputIP { set { _outputIp = value; CreateAugmentaClient(); } } - [Tooltip("Time in s before a connection without heartbeat is deleted. 0 = Never.")] - public float connectionTimeout = 60; - - public bool debug = false; - - private Dictionary _augmentaOutputs; // - private KeyValuePair _tmpOutput; - private List _outputsToDelete; - private OSCManagerControllable _controllable; - private NodeManager _nodeManager; private bool _initialized = false; - private bool _yoServerCreated = false; #region MonoBehaviour Implementation @@ -55,11 +38,6 @@ private void Update() { if (!_initialized) Initialize(); - - if (!_yoServerCreated) - CreateYoServer(); - - UpdateOutputsTimers(); } #endregion @@ -67,54 +45,13 @@ private void Update() { void Initialize() { activeManager = this; - _augmentaOutputs = new Dictionary(); - _outputsToDelete = new List(); - _controllable = FindObjectOfType(); - _nodeManager = FindObjectOfType(); - CreateYoServer(); CreateAugmentaClient(); _initialized = true; } - /// - /// Increase output timers and delete timed out outputs - /// - void UpdateOutputsTimers() { - - _outputsToDelete.Clear(); - - for(int i=0; i<_augmentaOutputs.Count; i++) { - - _tmpOutput = _augmentaOutputs.ElementAt(i); - - //Increase output timers - _augmentaOutputs[_tmpOutput.Key] = _tmpOutput.Value + Time.deltaTime; - - //Check for deletion only if connection timeout is strictly positive - if (connectionTimeout <= 0) - continue; - - //Mark for deletion - if (_augmentaOutputs[_tmpOutput.Key] > connectionTimeout) - _outputsToDelete.Add(_tmpOutput.Key); - } - - //Delete timed out outputs - foreach(var output in _outputsToDelete) { - - if(OSCMaster.Clients.ContainsKey(output)) - OSCMaster.RemoveClient(output); - - _augmentaOutputs.Remove(output); - - if (debug) - Debug.Log("Output " + output + " timed out."); - } - } - /// /// Create client to send Augmenta message /// @@ -137,406 +74,5 @@ public void SendAugmentaMessage(OSCMessage message) { Initialize(); OSCMaster.Clients["AugmentaSimulatorOutput"].Send(message); - - foreach (var output in _augmentaOutputs) - OSCMaster.Clients[output.Key].Send(message); - } - - /// - /// Create receiver for yo protocol - /// - void CreateYoServer() { - - if (OSCMaster.Receivers.ContainsKey("AugmentaYo")) - return; - - try { - OSCMaster.CreateReceiver("AugmentaYo", yoPort); - OSCMaster.Receivers["AugmentaYo"].messageReceived += OnYoMessageReceived; - zeroconfManager.Setup(yoPort); - _yoServerCreated = true; - } catch { - Debug.LogError("Failed to create Augmenta Yo server."); - yoPort++; - } - } - - /// - /// Answer yo protocol - /// - void OnYoMessageReceived(OSCMessage message) { - - string[] addressSplit = message.Address.Split('/'); - - switch (addressSplit[1]) { - - case "yo": - - //Answer yo - string yoIP = message.Data[0].ToString(); - int yoPort = (int)message.Data[1]; - - OSCMessage wassupMessage = new OSCMessage("/wassup"); - - wassupMessage.Append(NetworkManager.GetIpv4()); - wassupMessage.Append(NetworkManager.GetMacAddress()); - wassupMessage.Append(_nodeManager ? _nodeManager.nodeName : "Simulator"); - wassupMessage.Append(_nodeManager ? string.Join(",", _nodeManager.tagsList) : ""); - - if (debug) - Debug.Log("Answering yo from "+yoIP+":"+yoPort+" with " + NetworkManager.GetIpv4() + " and " + NetworkManager.GetMacAddress()); - - try - { - OSCMaster.SendMessage(wassupMessage, yoIP, yoPort); - }catch(System.Exception e) - { - Debug.LogWarning("Error sending OSC to " + yoIP + ":" + yoPort + " (" + e.Message + ")"); - } - - break; - - case "connect": - - switch (yoVersion) { - case 1: - HandleConnectV1(message); - break; - - case 2: - HandleConnectV2(message); - break; - } - - break; - - case "disconnect": - - switch (yoVersion) { - case 1: - HandleDisconnectV1(message); - break; - - case 2: - HandleDisconnectV2(message); - break; - } - - break; - - case "ping": - - //Answer ping - string pongIP = message.Data[0].ToString(); - int pongPort = (int)message.Data[1]; - - OSCMessage pongMessage = new OSCMessage("/pong"); - - if (debug) - Debug.Log("Answering ping from " + pongIP + ":" + pongPort); - - OSCMaster.SendMessage(pongMessage, pongIP, pongPort); - - break; - - case "info": - - //Answer info - string infoIP = message.Data[0].ToString(); - int infoPort = (int)message.Data[1]; - - if (debug) - Debug.Log("Answering info from " + infoIP + ":" + infoPort + " with " + NetworkManager.GetIpv4() + " Augmenta Simulator " + NetworkManager.GetMacAddress() + " " + Application.version + " " + _controllable.currentPreset + " Simulator Simulated"); ; - - SendInfoMessages(infoIP, infoPort); - break; - - case "heartbeat": - - switch (yoVersion) { - case 1: - HandleHeartbeatV1(message); - break; - - case 2: - HandleHeartbeatV2(message); - break; - } - - break; - } - } - - /// - /// Returns an ID based on the IP address and the port - /// - /// - /// - /// - string GetIDFromIPAndPort(string IP, int port) { - - return string.Join(":", new string[] { IP, port.ToString() }); - } - - void HandleConnectV1(OSCMessage message) { - - //Answer connect - string outputIP = message.Data[1].ToString(); - int outputPort = (int)message.Data[2]; - - string outputID = GetIDFromIPAndPort(outputIP, outputPort); - - //Create output client - if (!OSCMaster.Clients.ContainsKey(outputID)) - OSCMaster.CreateClient(outputID, outputIP, outputPort); - - if (!_augmentaOutputs.ContainsKey(outputID)) - _augmentaOutputs.Add(outputID, 0); - - if (debug) - Debug.Log("Created output " + outputID); - } - - void HandleConnectV2(OSCMessage message) { - - //Answer connect - string outputIP = message.Data[0].ToString(); - int outputPort = (int)message.Data[1]; - string protocolType = message.Data[2].ToString(); - int version = (int)message.Data[3]; - - if(protocolType != "osc" && protocolType != "OSC") { - if (debug) - Debug.Log("Can only create osc protocol type."); - - return; - } - - string outputID = GetIDFromIPAndPort(outputIP, outputPort); - - //Create output client - if (!OSCMaster.Clients.ContainsKey(outputID)) - OSCMaster.CreateClient(outputID, outputIP, outputPort); - - if (!_augmentaOutputs.ContainsKey(outputID)) - _augmentaOutputs.Add(outputID, 0); - - if (debug) - Debug.Log("Created output " + outputID); - } - - void HandleDisconnectV1(OSCMessage message) { - - //Answer disconnect - string disconnectIP = message.Data[0].ToString(); - int disconnectPort = (int)message.Data[1]; - - string disconnectID = GetIDFromIPAndPort(disconnectIP, disconnectPort); - - if (OSCMaster.Clients.ContainsKey(disconnectID)) { - - OSCMaster.RemoveClient(disconnectID); - - if (debug) - Debug.Log("Removed output " + disconnectID); - - _augmentaOutputs.Remove(disconnectID); - } - } - - void HandleDisconnectV2(OSCMessage message) { - - //Answer disconnect - string disconnectIP = message.Data[0].ToString(); - int disconnectPort = (int)message.Data[1]; - - if (message.Data.Count > 2) - { - string protocolType = message.Data[2].ToString(); - int version = (int)message.Data[3]; - } - - string disconnectID = GetIDFromIPAndPort(disconnectIP, disconnectPort); - - if (OSCMaster.Clients.ContainsKey(disconnectID)) { - - OSCMaster.RemoveClient(disconnectID); - - if (debug) - Debug.Log("Removed output " + disconnectID); - - _augmentaOutputs.Remove(disconnectID); - } - } - - void HandleHeartbeatV1(OSCMessage message) { - - //Answer heartbeat - string heartbeatIP = message.Data[1].ToString(); - int heartbeatPort = (int)message.Data[2]; - - string heartbeatID = GetIDFromIPAndPort(heartbeatIP, heartbeatPort); - - if (debug) - Debug.Log("Received heartbeat for " + heartbeatID); - - if (_augmentaOutputs.ContainsKey(heartbeatID)) - _augmentaOutputs[heartbeatID] = 0; - } - - void HandleHeartbeatV2(OSCMessage message) { - - //Answer heartbeat - string heartbeatIP = message.Data[0].ToString(); - int heartbeatPort = (int)message.Data[1]; - string protocolType = message.Data[2].ToString(); - int version = (int)message.Data[3]; - - if (protocolType != "osc" && protocolType != "OSC") { - if (debug) - Debug.Log("Can only send osc protocol type."); - - return; - } - - string heartbeatID = GetIDFromIPAndPort(heartbeatIP, heartbeatPort); - - if (debug) - Debug.Log("Received heartbeat for " + heartbeatID); - - if (_augmentaOutputs.ContainsKey(heartbeatID)) - _augmentaOutputs[heartbeatID] = 0; - - } - - void SendInfoMessages(string infoIP, int infoPort) { - - switch (ProtocolVersionManager.protocolVersion) { - case ProtocolVersionManager.AugmentaProtocolVersion.V1: - SendInfoMessagesV1(infoIP, infoPort); - break; - case ProtocolVersionManager.AugmentaProtocolVersion.V2: - SendInfoMessagesV2(infoIP, infoPort); - break; - } - - } - - void SendInfoMessagesV1(string infoIP, int infoPort) { - - OSCMessage infoMessage = new OSCMessage("/info"); - - infoMessage.Append(NetworkManager.GetIpv4()); - infoMessage.Append("Augmenta Simulator"); - infoMessage.Append(NetworkManager.GetMacAddress()); - infoMessage.Append(Application.version); - infoMessage.Append(_controllable.currentPreset != "" ? _controllable.currentPreset : "None"); - infoMessage.Append("Simulator"); - infoMessage.Append("Simulated"); - - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - } - - void SendInfoMessagesV2(string infoIP, int infoPort) { - - //Fusion - OSCMessage infoMessage = new OSCMessage("/info/name"); - if (_nodeManager) { - infoMessage.Append(_nodeManager.nodeName); - } else { - infoMessage.Append("Augmenta Simulator"); - } - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/type"); - if (_nodeManager) { - infoMessage.Append("Node"); - } else { - infoMessage.Append("Simulator"); - } - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/mac"); - infoMessage.Append(NetworkManager.GetMacAddress()); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/ip"); - infoMessage.Append(NetworkManager.GetIpv4()); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/version"); - infoMessage.Append(Application.version); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/currentFile"); - infoMessage.Append(_controllable.currentPreset != "" ? _controllable.currentPreset : "None"); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/protocolAvailable"); - infoMessage.Append("OSC"); - infoMessage.Append("1"); - infoMessage.Append("2"); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - if (_nodeManager) { - //Node - infoMessage = new OSCMessage("/info/sensor/type"); - infoMessage.Append(_nodeManager.sensorType); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/sensor/brand"); - infoMessage.Append(_nodeManager.sensorBrand); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/sensor/name"); - infoMessage.Append(_nodeManager.sensorName); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/sensor/hFov"); - infoMessage.Append(_nodeManager.sensorHFOV); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/sensor/vFov"); - infoMessage.Append(_nodeManager.sensorVFOV); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/floorMode"); - infoMessage.Append(_nodeManager.floorMode); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/floorState"); - infoMessage.Append(_nodeManager.floorState); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/backgroundMode"); - infoMessage.Append(_nodeManager.backgroundMode); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/debug/pipeName"); - infoMessage.Append(_nodeManager.debugPipeName); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/debug/sensor"); - infoMessage.Append(_nodeManager.debugSensor); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/debug/videoPipe"); - infoMessage.Append(_nodeManager.debugVideoPipe); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/debug/trackingPipe"); - infoMessage.Append(_nodeManager.debugTrackingPipe); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/debug/pid"); - infoMessage.Append(_nodeManager.debugPID); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - - infoMessage = new OSCMessage("/info/tags"); - foreach(string tag in _nodeManager.tagsList) - infoMessage.Append(tag); - OSCMaster.SendMessage(infoMessage, infoIP, infoPort); - } - } } diff --git a/Assets/Scripts/Network/ZeroconfManager.cs b/Assets/Scripts/Network/ZeroconfManager.cs deleted file mode 100644 index 398cb5f..0000000 --- a/Assets/Scripts/Network/ZeroconfManager.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using Mono.Zeroconf; - -public class ZeroconfManager : MonoBehaviour -{ - private RegisterService service; - - private string _name = "Simulator"; - private int _port = 36278; - private Dictionary _keys; - - void OnDisable() { - - if (service != null) DestroyService(); - } - - void UpdateService() - { - if (service != null) DestroyService(); - - service = new RegisterService(); - service.Name = "Augmenta - " + _name; - service.RegType = "_osc._udp"; - service.ReplyDomain = "local."; - service.UPort = (ushort)_port; - - if (_keys != null && _keys.Count > 0) - { - TxtRecord txt = new TxtRecord(); - foreach (KeyValuePair kv in _keys) { - txt.Add(kv.Key, kv.Value); - } - service.TxtRecord = txt; - } - - service.Register(); - } - - void DestroyService() { - - service.Dispose(); - } - - public void Setup(int newPort = 36278, string newName = "Simulator", Dictionary newKeys = null) - { - if(newKeys == null) { - newKeys = new Dictionary(); - newKeys.Add("mac", NetworkManager.GetMacAddress()); - } - - _name = newName; - _port = newPort; - _keys = newKeys; - UpdateService(); - } -} diff --git a/Assets/Scripts/Network/ZeroconfManager.cs.meta b/Assets/Scripts/Network/ZeroconfManager.cs.meta deleted file mode 100644 index ba0f1a0..0000000 --- a/Assets/Scripts/Network/ZeroconfManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c81078e2b27379140a5eea674206f0a3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: