示例#1
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);
            }
        }
示例#2
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;
                }
            }
        }
示例#3
0
        public static void RemovePrefix(string uriPrefix, HttpListener httpListener)
        {
            object syncRoot = ((ICollection)EndPointManager._ipToEndpoints).SyncRoot;

            lock (syncRoot)
            {
                EndPointManager.removePrefix(uriPrefix, httpListener);
            }
        }
示例#4
0
        public static void RemovePrefix(string uriPrefix, WebSocketSharp.Net.HttpListener listener)
        {
            object syncRoot = ((ICollection)EndPointManager._endpoints).SyncRoot;

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