public void MonitorThreadProc() { while (true) { OSCManager.Update(); Process[] processes = Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(_processName)); if (processes != null && processes.Length > 0) { foreach (Process p in processes) { if (!p.Responding || _restartRequested) { p.Kill(); } } } else { // Didn't find the process, start it now Process p = new Process(); p.StartInfo.FileName = _processName; p.StartInfo.UseShellExecute = true; p.StartInfo.LoadUserProfile = true; p.Start(); Thread.Sleep(10000); } _restartRequested = false; Thread.Sleep(50); } }
void SendOSC(Vector3 pos, Vector3 rot, Rect rect) { OSCManager manager = OSCManager.instance; OSCMessage msg = OSCMessage.Create("/calibration", pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, rect.x, rect.y, rect.width, rect.height); manager.SendPacket(msg, ipAddress, 7000); }
void Awake() { // [OSC] create new OSC connection pointing to localhost/127.0.0.1:6666 myOSCScript = new OSCScript("127.0.0.1", 6666); myOSCManager = new OSCManager(8000); myOSCManager.Connect(); }
bool OnServerStatus(OSCMessage msg) { if (_serverAddress == null) { _serverAddress = msg.From; OSCManager.SendTo(new OSCMessage("/unity/client/show/join", _clientConfig.Id), msg.From); } return(true); }
// Update is called once per frame void Update() { OSCManager.Update(); if (_theShow != null) { if ((System.DateTime.Now - _lastStatusTime).TotalSeconds > 5) { OSCManager.SendToAll(new OSCMessage("/unity/server/status", null)); _lastStatusTime = System.DateTime.Now; } if (_timerSeconds > 0) { System.TimeSpan ts = (System.DateTime.Now - _timerMarker); if (ts.TotalSeconds >= _timerSeconds) { // Timer expired, go to the next step Show_ExecuteStep(); } else { SetSecondaryShowText((_timerSeconds - ts.TotalSeconds).ToString("N3")); } } // Bypass gesture with space bar if (_waitingForGesture != null) { if (Input.GetKeyDown(KeyCode.Space)) { Show_ExecuteStep(); } } } foreach (var kvp in _knownClients) { if (kvp.Value.Status == ClientInfo.ConnectionStatus.Normal && ((System.DateTime.Now - kvp.Value.LastSeenTime).TotalSeconds > 5)) { // This client hasn't been seen for 5 seconds kvp.Value.Status = ClientInfo.ConnectionStatus.NotResponding; } if (kvp.Value.Status == ClientInfo.ConnectionStatus.NotResponding && ((System.DateTime.Now - kvp.Value.RestartMsgTime).TotalSeconds > 2)) { // Its been more than 2 seconds since the restarter was notified, send it again OSCManager.SendTo(new OSCMessage("/unity/client/restart"), kvp.Value.IPAddress, RemoteManagerPort); kvp.Value.RestartMsgTime = System.DateTime.Now; } } }
public ProcessMonitor(string processName) { OSCManager.Initialize("255.255.255.255", 19876); OSCManager.ListenToAddress("/unity/client/restart", OnRestartClient); _processName = processName; _monitorThread = new Thread(new ThreadStart(MonitorThreadProc)) { Name = "Monitor Thread" }; _monitorThread.Start(); }
private void OnEnable() { script = target as OSCManager; mode = serializedObject.FindProperty("mode"); receiverId = serializedObject.FindProperty("receiverId"); receiverPort = serializedObject.FindProperty("receiverPort"); senderId = serializedObject.FindProperty("senderId"); targetIp = serializedObject.FindProperty("targetIp"); targetPort = serializedObject.FindProperty("targetPort"); }
void OnApplicationQuit() { foreach (KeyValuePair <string, ClientData> pair in _clients) { pair.Value.client.Close(); } foreach (KeyValuePair <string, ServerData> pair in _servers) { pair.Value.server.Close(); } _instance = null; }
void Update() { if (handler == null) { handler = FindObjectOfType(typeof(OSCManager)) as OSCManager; } // properties if (_controlIndex == 0) { // check if we have different incoming values to send or if we want to send every frames if (propertyObject.GetValue(objectComponent, null).Equals(oldPropertyObject) && !sendEveryFrame) { //print("equal"); } else { oldPropertyObject = propertyObject.GetValue(objectComponent, null); List <object> objects = new List <object>(); objects = listConvertedOSC(propertyObject); // print ("handler = "+propertyObject.GetValue(objectComponent,null)+" type="+propertyObject.GetValue(objectComponent,null).GetType()+" name="+propertyObject); string clientName = "RemoteClient-" + OSCtransmitPort.port; if (objects != null) { handler.SendMessageToClient(clientName, address, objects); } } } else if (_controlIndex == 1) // method sending not include yet { if (methodObject != null) { // for now its just for blendhshapes // TODO: create a generic method for sending all the data that derives from methodObject if (methodObject.Name == "GetBlendShapeWeight") { GameObject objectTemp = this.gameObject; SkinnedMeshRenderer meshTemp = objectTemp.GetComponent <SkinnedMeshRenderer>(); // print (" blendshape ---------- " + meshTemp.GetBlendShapeWeight(_extra)); // Extra is used as the blendshape index string clientName = "RemoteClient-" + OSCtransmitPort.port; List <object> objects = new List <object>(); objects.Add(meshTemp.GetBlendShapeWeight(_extra)); // Extra is used as the blendshape index handler.SendMessageToClient(clientName, address, objects); // send OSC message to client } } } }
void Initialize() { activeManager = this; _augmentaOutputs = new Dictionary <string, float>(); _outputsToDelete = new List <string>(); _controllable = FindObjectOfType <OSCManagerControllable>(); _nodeManager = FindObjectOfType <NodeManager>(); CreateYoServer(); CreateAugmentaClient(); _initialized = true; }
IPEndPoint sendEndPort = new IPEndPoint(IPAddress.Parse("127.0.0.1"), Config.OSC_PORT); // "localhost" does not recognize OSX native #endregion #region life cycle void Awake() { _instance = this; // assign tracker trackers = new Dictionary <string, AbstractTracker>(); trackers.Add(Config.OSC_ADDRESS_BALL, new BallTracker(Config.BALL_MAX_COUNT)); trackers.Add(Config.OSC_ADDRESS_POCKET, new PocketTracker()); trackers.Add(Config.OSC_ADDRESS_COLLISION, new CollisionTracker()); trackers.Add(Config.OSC_ADDRESS_CUE, new CueTracker()); trackers.Add(Config.OSC_ADDRESS_CALIBRATION, new CaliblationTracker()); oscManager = OSCManager.instance; oscManager.LocalPort = Config.OSC_PORT; }
bool OnJoinShow(OSCMessage msg) { int clientId = -1; if (msg.Args != null && msg.Args.Length > 0) { clientId = (int)msg.Args[0]; } if (clientId >= 0) { if (!_knownClients.ContainsKey(clientId)) { _knownClients[clientId] = new ClientInfo(clientId, msg.From); } _knownClients[clientId].MarkLastSeen(); _knownClients[clientId].IPAddress = msg.From; } // This client is just joining right now, send them everything from the last scene load up until the current step for (int i = _lastSceneMarker; i < _theShow.currentEventGroupIndex; i++) { EventGroup eg = _theShow.eventGroups[i]; foreach (Event evt in eg.events) { switch (evt.action) { case "loadScene": Debug.LogFormat("SHOW - Sending Loading scene: {0} to client: ({2}){1} ", evt.arg1, msg.From, clientId); _lastSceneMarker = _theShow.currentEventGroupIndex - 1; OSCManager.SendTo(new OSCMessage("/unity/server/show/loadScene", evt.arg1), msg.From); break; case "showObject": Debug.LogFormat("SHOW - Sending showObject: {0} to cleint: ({2}){1} ", evt.arg1, msg.From, clientId); OSCManager.SendTo(new OSCMessage("/unity/server/show/showObject", evt.arg1), msg.From); break; case "hideObject": Debug.LogFormat("SHOW - Sending hideObject: {0} to cleint: ({2}){1} ", evt.arg1, msg.From, clientId); OSCManager.SendTo(new OSCMessage("/unity/server/show/hideObject", evt.arg1), msg.From); break; } } } return(true); }
// Update is called once per frame void Update() { if ((System.DateTime.Now - _lastStatusTime).TotalSeconds >= 2) { OSCManager.SendToAll(new OSCMessage("/unity/client/status", _clientConfig.Id)); _lastStatusTime = System.DateTime.Now; } if (_pendingSceneLoad != null && _pendingSceneLoad.isDone) { _pendingSceneLoad = null; } if (_pendingSceneLoad == null) { OSCManager.Update(); // Only process packets if pending scene loads are all done } }
// Use this for initialization void Start() { _knownClients = new Dictionary <int, ClientInfo>(); SharedLogger.ListenToMessages(LogMessageHandler); OSCManager.Initialize("239.1.2.3"); OSCManager.ListenToAddress("/unity/client/show/join", OnJoinShow); OSCManager.ListenToAddress("/unity/client/status", OnClientStatus); OSCManager.ListenToAddress("/unity/client/restarting", OnClientRestarting); if (Debug.isDebugBuild && File.Exists("show_debug.json")) { LoadJSON(File.ReadAllText("show_debug.json")); } else if (!string.IsNullOrEmpty(JSON_URL)) { StartCoroutine(FetchShowScript()); } }
// Use this for initialization void Start() { DontDestroyOnLoad(gameObject); OSCManager.Initialize("239.1.2.3"); OSCManager.ListenToAddress("/unity/server/status", OnServerStatus); OSCManager.ListenToAddress("/unity/server/show/loadScene", OnLoadScene); OSCManager.ListenToAddress("/unity/server/show/showObject", OnShowHideObject); OSCManager.ListenToAddress("/unity/server/show/hideObject", OnShowHideObject); try { _clientConfig = JsonUtility.FromJson <ClientConfig>(System.IO.File.ReadAllText("client_config.json")); } catch (System.Exception ex) { _clientConfig = new ClientConfig(); _clientConfig.id = "-2"; Debug.LogError(ex.ToString()); } }
public Node <INode> GetNode(string nodeName) { switch (nodeName) { case OSCManager.NAME: INode nodeOsc = new OSCManager() as INode; return(new Node <INode> (nodeOsc)); case OSCReceive.NAME: INode nodeOSCFilter = new OSCReceive() as INode; return(new Node <INode> (nodeOSCFilter)); case OSCSend.NAME: INode nodeOSCSend = new OSCSend() as INode; return(new Node <INode> (nodeOSCSend)); default: return(null); } }
// Initialization void Start() { if (propertyObject == null) { Type typeComponent = objectComponent.GetType(); const BindingFlags flags = /*BindingFlags.NonPublic | */ BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static; PropertyInfo[] properties = typeComponent.GetProperties(flags); if (properties.Length > _generalIndex) { propertyObject = properties[_generalIndex]; oldPropertyObject = propertyObject.GetValue(objectComponent, null); } } if (methodObject == null) { Type typeComponent = objectComponent.GetType(); const BindingFlags flags = /*BindingFlags.NonPublic | */ BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static; MethodInfo[] methods = typeComponent.GetMethods(flags); if (methods.Length > _generalIndex) { methodObject = methods[_generalIndex]; } // print (" This GameObject="+this.name+" | component=" + objectComponent+" | type="+typeComponent+" | prop="+propertyObject); } handler = FindObjectOfType(typeof(OSCManager)) as OSCManager; requirements = new ObjectRequirements(); }
void Update() { if (enableFlag) { // DestroyAllTangibles has to be called within Update function if (trackersManager) { // prevent trying to access old tangibles gameObjects not alive anymore trackersManager.DestroyAllTrackers(); } if (isServer) { oscManager = GetComponentInChildren <OSCManager>(); oscManager.CreateServers(); trackersManager = GetComponentInChildren <TrackersManagerOSC>(); trackersManager.AttachOscServer(); } enableFlag = false; } }
bool Show_DoEvent(Event evt) { switch (evt.action) { case "loadScene": Debug.Log("SHOW - Loading scene: " + evt.arg1); _lastSceneMarker = _theShow.currentEventGroupIndex - 1; OSCManager.SendToAll(new OSCMessage("/unity/server/show/loadScene", evt.arg1)); break; case "showObject": Debug.Log("SHOW - showObject: " + evt.arg1); OSCManager.SendToAll(new OSCMessage("/unity/server/show/showObject", evt.arg1)); break; case "hideObject": Debug.Log("SHOW - hideObject: " + evt.arg1); OSCManager.SendToAll(new OSCMessage("/unity/server/show/hideObject", evt.arg1)); break; case "goto": Debug.Log("SHOW - goto: " + evt.arg1); for (int i = 0; i < _theShow.eventGroups.Count; i++) { if (_theShow.eventGroups[i].name == evt.arg1) { _theShow.currentEventGroupIndex = i; Show_ExecuteStep(); return(false); } } break; default: Debug.LogError("Unsupported event action encountered: " + evt.action); break; } return(true); }
void Start() { manager = OSCManager.instance; manager.LocalPort = 9000; }
void Awake() { oscManager = GetComponent <OSCManager>(); }
void OnEnable() { oscManager = OSCManager.instance; oscManager.LocalPort = port; oscManager.OnMessage += OnOSCMessage; }
void Awake() { oscManager = GetComponent<OSCManager>(); }
public void Kill() { OSCManager.Shutdown(); _monitorThread.Abort(); }
private void OnApplicationQuit() { OSCManager.Shutdown(); }
public bool OnRestartClient(OSCMessage msg) { _restartRequested = true; OSCManager.SendTo(new OSCMessage("/unity/client/restarting"), msg.From, 9876); return(true); }
void Show_ExecuteStep() { // Reset stop conditions _timerSeconds = -1; _waitingForGesture = null; _waitingForTrigger = null; // Grab the next step EventGroup step = _theShow.eventGroups[_theShow.currentEventGroupIndex++]; string stepName = string.Format("([0]){1}", _theShow.currentEventGroupIndex, step.name); Debug.Log("Executing step: " + stepName); if (ShowStep_Name != null) { ShowStep_Name.text = stepName; } // Execute the event actions foreach (Event evt in step.events) { if (!Show_DoEvent(evt)) { return; // Event wants to not continue this script path. } } // If this step doesn't have a stop condition, execute the next step if (step.stopCondition == null) { Show_ExecuteStep(); } else { if (ShowStep_StopCondition != null) { ShowStep_StopCondition.text = step.stopCondition.type; } switch (step.stopCondition.type) { case "trigger": _waitingForTrigger = step.stopCondition.arg1; SetSecondaryShowText(_waitingForTrigger); break; case "timer": _timerSeconds = ParseTimer(step.stopCondition.arg1); _timerMarker = System.DateTime.Now; break; case "gesture": _waitingForGesture = step.stopCondition.arg1; SetSecondaryShowText(_waitingForGesture); break; case "oscMessage": _waitingForOSCMessage = step.stopCondition.arg1; SetSecondaryShowText(_waitingForOSCMessage); OSCManager.ListenToAddress(_waitingForOSCMessage, OnOSCMessage); break; default: Debug.LogError("Unknown stop condition type: " + step.stopCondition.type); break; } } }
void OnEnable() { oscManager = OSCManager.instance; oscManager.LocalPort = port; }
public void AddListener(OSCManager.OscMessageDelegate listener) { oscManager.OnMessage += listener; }
bool OnOSCMessage(OSCMessage msg) { OSCManager.ForgetAddress(_waitingForOSCMessage); Show_ExecuteStep(); return(true); }