Пример #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="s"></param>
 public HttpServer(Server s)
 {
     this.s = s;
     s.Connect += new ClientEvent (ClientConnect);
     //handlers.Add (new FallbackHandler ());
     HttpServer.singletonServer = this;
 }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        /*
        public Session RequestSession (HttpRequest req)
        {
            if (req.Session != null) {
                if (sessions[req.Session.ID] == req.Session)
                    return req.Session;
            }
            req.Session = new Session (req.From);
            sessions[req.Session.ID] = req.Session;
            return req.Session;
        }
        */
        /// <summary>
        /// 
        /// </summary>
        /*
        void CleanUpSessions (bool unconditionally)
        {
            ICollection keys = sessions.Keys;
            ArrayList toRemove = new ArrayList ();
            foreach (string k in keys) {
                Session s = (Session)sessions[k];
                int time = (int)((DateTime.Now - s.LastTouched).TotalSeconds);
                if ((time > sessionTimeout) || unconditionally) {
                    toRemove.Add (k);
                }
            }
            foreach (object k in toRemove)
                sessions.Remove (k);
        }

        void CleanUpSessions ()
        {
            CleanUpSessions (false);
        }
        */
        /// <summary>
        /// 
        /// </summary>
        /// <param name="s"></param>
        /// <param name="ci"></param>
        /// <returns></returns>
        bool ClientConnect(Server s, ClientInfo ci)
        {
            ci.Delimiter = "\r\n\r\n";
            ci.Data = new ClientData (ci);
            ci.OnRead += new ConnectionRead (ClientRead);
            ci.OnReadBytes += new ConnectionReadBytes (ClientReadBytes);
            return true;
        }
Пример #3
0
 public bool Close()
 {
     bool result = false;
     try {
         if (s != null) {
             s.Close ();
             //CleanUpSessions (true);
             s = null;
             result = true;
         } else {
             result = false;
         }
     } catch (Exception e) {
     #if DEBUG
         SystemLogger.Log(SystemLogger.Module.CORE, "HttpServer: Close() failure: " + e.Source + " " + e.Message);
         result = false;
     #endif
     }
     return result;
 }