コード例 #1
0
ファイル: BaseHttpServer.cs プロジェクト: justasabc/opensim
        public bool RemoveLLSDHandler(string path, LLSDMethod handler)
        {
            lock (m_llsdHandlers)
            {
                LLSDMethod foundHandler;

                if (m_llsdHandlers.TryGetValue(path, out foundHandler) && foundHandler == handler)
                {
                    m_llsdHandlers.Remove(path);
                    return true;
                }
            }

            return false;
        }
コード例 #2
0
ファイル: BaseHttpServer.cs プロジェクト: justasabc/opensim
 public bool AddLLSDHandler(string path, LLSDMethod handler)
 {
     lock (m_llsdHandlers)
     {
         if (!m_llsdHandlers.ContainsKey(path))
         {
             m_llsdHandlers.Add(path, handler);
             return true;
         }
     }
     return false;
 }
コード例 #3
0
        public bool RemoveLLSDHandler(string path, LLSDMethod handler)
        {
            try
            {
                if (handler == m_llsdHandlers[path])
                {
                    m_llsdHandlers.Remove(path);
                    return true;
                }
            }
            catch (KeyNotFoundException)
            {
                // This is an exception to prevent crashing because of invalid code
            }

            return false;
        }
コード例 #4
0
ファイル: BaseHttpServer.cs プロジェクト: justasabc/opensim
        private bool TryGetLLSDHandler(string path, out LLSDMethod llsdHandler)
        {
            llsdHandler = null;
            // Pull out the first part of the path
            // splitting the path by '/' means we'll get the following return..
            // {0}/{1}/{2}
            // where {0} isn't something we really control 100%

            string[] pathbase = path.Split('/');
            string searchquery = "/";

            if (pathbase.Length < 1)
                return false;

            for (int i=1; i<pathbase.Length; i++)
            {
                searchquery += pathbase[i];
                if (pathbase.Length-1 != i)
                    searchquery += "/";
            }

            // while the matching algorithm below doesn't require it, we're expecting a query in the form
            //
            //   [] = optional
            //   /resource/UUID/action[/action]
            //
            // now try to get the closest match to the reigstered path
            // at least for OGP, registered path would probably only consist of the /resource/

            string bestMatch = null;

            lock (m_llsdHandlers)
            {
                foreach (string pattern in m_llsdHandlers.Keys)
                {
                    if (searchquery.ToLower().StartsWith(pattern.ToLower()))
                    {
                        if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length)
                        {
                            // You have to specifically register for '/' and to get it, you must specificaly request it
                            //
                            if (pattern == "/" && searchquery == "/" || pattern != "/")
                                bestMatch = pattern;
                        }
                    }
                }
    
                if (String.IsNullOrEmpty(bestMatch))
                {
                    llsdHandler = null;
                    return false;
                }
                else
                {
                    llsdHandler = m_llsdHandlers[bestMatch];
                    return true;
                }
            }
        }
コード例 #5
0
 public LLSDStreamhandler(
     string httpMethod, string path, LLSDMethod <TRequest, TResponse> method, string name, string description)
     : base(httpMethod, path, name, description)
 {
     m_method = method;
 }
コード例 #6
0
 public LLSDStreamhandler(string httpMethod, string path, LLSDMethod <TRequest, TResponse> method)
     : this(httpMethod, path, method, null, null)
 {
 }
コード例 #7
0
ファイル: LLSDStreamHandler.cs プロジェクト: 4U2NV/opensim
 public LLSDStreamhandler(string httpMethod, string path, LLSDMethod <TRequest, TResponse> method)
     : base(httpMethod, path)
 {
     m_method = method;
 }
コード例 #8
0
        public bool AddLLSDHandler(string path, LLSDMethod handler)
        {
            try
            {
                m_llsdHandlers.AddIfNotExists(path, delegate() { return handler; });
                return true;
            }
            catch(ThreadedClasses.RwLockedDictionary<string, LLSDMethod>.KeyAlreadyExistsException)
            {

            }
            return false;
        }
コード例 #9
0
 public bool RemoveLLSDHandler(string path, LLSDMethod handler)
 {
     return m_llsdHandlers.RemoveIf(path, delegate(LLSDMethod foundHandler) { return foundHandler == handler; });
 }