Ejemplo n.º 1
0
        public bool IsStreamAvailable(out LSLStreamInfoWrapper info, string streamName = "", string streamType = "", string hostName = "")
        {
            var result = streams.Where(i => (streamName.Length == 0 || i.name.Equals(streamName)) && (streamType.Length == 0 || i.type.Equals(streamType)) &&
                                       (hostName.Length == 0 || i.type.Equals(hostName)))
                         .ToList();

            if (result.Any())
            {
                info = result.First();
                return(true);
            }
            info = null;
            return(false);
        }
Ejemplo n.º 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));
            }
        }