예제 #1
0
        public virtual SessionDescription SetProfile(Profile newProfile)
        {
            AppLogger.Message("CommonStreamService.SetProfile " + newProfile.Name);
#if USE_GLOBAL_GRAPHSERVICELOCK
            lock (_graphServiceLock)
            {
#endif
            if (_graph != null)
            {
                try
                {
                    if (newProfile.Name.ToLowerInvariant().Contains("custom"))
                    {
                        CurrentProfile = newProfile;
                    }
                    else
                    {
                        CurrentProfile = _graph.FindProfile(newProfile.Name);
                    }
                    if (CurrentProfile != null)
                    {
                        _graph.ChangeProfile(CurrentProfile);
                    }
                    return(null);
                }
                catch (ServerGraphRebuildException exc)
                {
                    AppLogger.Dump(exc);
                    AppLogger.Message("CommonStreamService.SetProfile() caught ServerGraphRebuildException--opening a new graph");
                    _graph.Stop();
                    _graph.State = ServerGraphState.Aborted;
                    _graph.RemoveClient(this);
                    // Save newProfile in the dictionary
                    GraphManager.RemoveAndDisposeGraph(_graph);
                    this.OpenGraphRequest.Profile = CurrentProfile;
                    _graph = OpenGraph();
                    _graph.AddClient(this);
                    SessionDescription sd = _graph.FillOutSessionDescription(this.OpenGraphRequest);
                    return(sd);
                }
            }
            else
            {
                throw new ServiceHasNoGraphException();
            }
#if USE_GLOBAL_GRAPHSERVICELOCK
        }
#endif
        }