예제 #1
0
        private IEnumerator resolveContinuously()
        {
            while (resolve)
            {
                var results = resolver.results();

                foreach (var item in knownStreams)
                {
                    if (!results.Any(r => r.name().Equals(item.Name)))
                    {
                        if (onStreamLost.GetPersistentEventCount() > 0)
                        {
                            onStreamLost.Invoke(item);
                        }
                    }
                }

                // remove lost streams from cache
                knownStreams.RemoveAll(s => !results.Any(r => r.name().Equals(s.Name)));

                // add new found streams to the cache
                foreach (var item in results)
                {
                    if (!knownStreams.Any(s => s.Name == item.name() && s.Type == item.type()))
                    {
                        Debug.Log(string.Format("Found new Stream {0}", item.name()));

                        var newStreamInfo = new LSLStreamInfoWrapper(item);
                        knownStreams.Add(newStreamInfo);

                        if (onStreamFound.GetPersistentEventCount() > 0)
                        {
                            onStreamFound.Invoke(newStreamInfo);
                        }
                    }
                }

                yield return(new WaitForSecondsRealtime(0.1f));
            }
            yield return(null);
        }
예제 #2
0
        private IEnumerator ResolveContinuously()
        {
            while (true)
            {
                var results = resolver.Results();

                //foreach (var item in streams) {
                //if (!results.Any(r => r.Name().Equals(item.name))) {
                //if (onStreamLost.GetPersistentEventCount() > 0) { onStreamLost.Invoke(item); } } }
                //Replace by LINQ Expression

                foreach (LSLStreamInfoWrapper item in streams.Where(item => !results.Any(r => r.Name().Equals(item.name)))
                         .Where(item => onStreamLost.GetPersistentEventCount() > 0))
                {
                    onStreamLost.Invoke(item);
                }

                // remove lost streams from cache
                streams.RemoveAll(s => !results.Any(r => r.Name().Equals(s.name)));

                // add new found streams to the cache
                foreach (var item in results)
                {
                    if (!streams.Any(s => s.name == item.Name() && s.type == item.Type()))
                    {
                        Debug.Log($"Found new Stream {item.Name()}");

                        var newStreamInfo = new LSLStreamInfoWrapper(item);
                        streams.Add(newStreamInfo);

                        if (onStreamFound.GetPersistentEventCount() > 0)
                        {
                            onStreamFound.Invoke(newStreamInfo);
                        }
                    }
                }
                yield return(new WaitForSecondsRealtime(0.1f));
            }
        }
 private void OnStreamEvent(VkStreamEvent e)
 {
     StreamEvent?.Invoke(this, e);
 }
			public void InvokeStreamEvent(Vector2Int frequencyRange, float normalizedEnergy, float deltaEnergy = 0)
			{
				StreamEvent.Invoke (frequencyRange, normalizedEnergy, deltaEnergy);
			}