コード例 #1
0
        public static void AddListener(HttpListener httpListener)
        {
            List <string> list     = new List <string>();
            object        syncRoot = ((ICollection)EndPointManager._ipToEndpoints).SyncRoot;

            lock (syncRoot)
            {
                try
                {
                    foreach (string text in httpListener.Prefixes)
                    {
                        EndPointManager.addPrefix(text, httpListener);
                        list.Add(text);
                    }
                }
                catch
                {
                    foreach (string uriPrefix in list)
                    {
                        EndPointManager.removePrefix(uriPrefix, httpListener);
                    }
                    throw;
                }
            }
        }
コード例 #2
0
        public static void AddListener(WebSocketSharp.Net.HttpListener listener)
        {
            List <string> strs     = new List <string>();
            object        syncRoot = ((ICollection)EndPointManager._endpoints).SyncRoot;

            Monitor.Enter(syncRoot);
            try
            {
                try
                {
                    foreach (string prefix in listener.Prefixes)
                    {
                        EndPointManager.addPrefix(prefix, listener);
                        strs.Add(prefix);
                    }
                }
                catch
                {
                    foreach (string str in strs)
                    {
                        EndPointManager.removePrefix(str, listener);
                    }
                    throw;
                }
            }
            finally
            {
                Monitor.Exit(syncRoot);
            }
        }
コード例 #3
0
        public static void AddPrefix(string uriPrefix, HttpListener httpListener)
        {
            object syncRoot = ((ICollection)EndPointManager._ipToEndpoints).SyncRoot;

            lock (syncRoot)
            {
                EndPointManager.addPrefix(uriPrefix, httpListener);
            }
        }
コード例 #4
0
        public static void AddPrefix(string uriPrefix, WebSocketSharp.Net.HttpListener listener)
        {
            object syncRoot = ((ICollection)EndPointManager._endpoints).SyncRoot;

            Monitor.Enter(syncRoot);
            try
            {
                EndPointManager.addPrefix(uriPrefix, listener);
            }
            finally
            {
                Monitor.Exit(syncRoot);
            }
        }