private void newClient_ClientShutdown(HttpWebServerRequest sender) { if (HttpClients.Contains(sender) == true) { HttpClients.Remove(sender); } }
private void newClient_ResponseSent(HttpWebServerRequest request, HttpWebServerResponseData response) { if (response.Cache.CacheType == HttpWebServerCacheType.Cache && CachedResponses.ContainsKey(request.ToString()) == false) { CachedResponses.Add(request.ToString(), response); } }
// private AsyncCallback m_asyncAcceptCallback = new AsyncCallback(PRoConLayer.ListenIncommingLayerConnections); private void ListenIncommingWebRequests(IAsyncResult ar) { TcpClient tcpNewConnection = null; try { tcpNewConnection = Listener.EndAcceptTcpClient(ar); var newClient = new HttpWebServerRequest(tcpNewConnection.GetStream()); newClient.ProcessRequest += new ProcessResponseHandler(newClient_ProcessRequest); newClient.ResponseSent += new HttpWebServerRequest.ResponseSentHandler(newClient_ResponseSent); newClient.ClientShutdown += new HttpWebServerRequest.ClientShutdownHandler(newClient_ClientShutdown); HttpClients.Add(newClient); //if (this.m_tcpListener != null) { // this.m_tcpListener.BeginAcceptTcpClient(this.ListenIncommingWebRequests, null); //} } catch (Exception) { if (tcpNewConnection != null) { tcpNewConnection.Close(); } } try { if (Listener != null) { Listener.BeginAcceptTcpClient(ListenIncommingWebRequests, null); } } catch (Exception) { Shutdown(); } }
private void newClient_ProcessRequest(HttpWebServerRequest sender) { // Scrub the cache for old responses foreach (string key in new List <string>(CachedResponses.Keys)) { if (CachedResponses[key].Cache.TrashTime >= DateTime.Now) { CachedResponses.Remove(key); } } if (CachedResponses.ContainsKey(sender.ToString()) == true) { sender.Respond(CachedResponses[sender.ToString()]); } else if (ProcessRequest != null) { this.ProcessRequest(sender); } }
private void newClient_ProcessRequest(HttpWebServerRequest sender) { // Scrub the cache for old responses foreach (string key in new List <string>(this.m_cachedResponses.Keys)) { if (this.m_cachedResponses[key].Cache.TrashTime >= DateTime.Now) { this.m_cachedResponses.Remove(key); } } if (this.m_cachedResponses.ContainsKey(sender.ToString()) == true) { sender.Respond(this.m_cachedResponses[sender.ToString()]); } else if (this.ProcessRequest != null) { FrostbiteConnection.RaiseEvent(this.ProcessRequest.GetInvocationList(), sender); } }
private void newClient_ResponseSent(HttpWebServerRequest request, HttpWebServerResponseData response) { if (response.Cache.CacheType == HttpWebServerCacheType.Cache && this.m_cachedResponses.ContainsKey(request.ToString()) == false) { this.m_cachedResponses.Add(request.ToString(), response); } }
private void newClient_ProcessRequest(HttpWebServerRequest sender) { // Scrub the cache for old responses foreach (string key in new List<string>(this.m_cachedResponses.Keys)) { if (this.m_cachedResponses[key].Cache.TrashTime >= DateTime.Now) { this.m_cachedResponses.Remove(key); } } if (this.m_cachedResponses.ContainsKey(sender.ToString()) == true) { sender.Respond(this.m_cachedResponses[sender.ToString()]); } else if (this.ProcessRequest != null) { FrostbiteConnection.RaiseEvent(this.ProcessRequest.GetInvocationList(), sender); } }
private void newClient_ClientShutdown(HttpWebServerRequest sender) { if (this.m_httpClients.Contains(sender) == true) { this.m_httpClients.Remove(sender); } }
// private AsyncCallback m_asyncAcceptCallback = new AsyncCallback(PRoConLayer.ListenIncommingLayerConnections); private void ListenIncommingWebRequests(IAsyncResult ar) { TcpClient tcpNewConnection = null; try { tcpNewConnection = this.m_tcpListener.EndAcceptTcpClient(ar); HttpWebServerRequest newClient = new HttpWebServerRequest(tcpNewConnection.GetStream()); newClient.ProcessRequest += new HttpWebServer.ProcessResponseHandler(newClient_ProcessRequest); newClient.ResponseSent += new HttpWebServerRequest.ResponseSentHandler(newClient_ResponseSent); newClient.ClientShutdown += new HttpWebServerRequest.ClientShutdownHandler(newClient_ClientShutdown); this.m_httpClients.Add(newClient); //if (this.m_tcpListener != null) { // this.m_tcpListener.BeginAcceptTcpClient(this.ListenIncommingWebRequests, null); //} } catch (Exception) { if (tcpNewConnection != null) { tcpNewConnection.Close(); } } try { if (this.m_tcpListener != null) { this.m_tcpListener.BeginAcceptTcpClient(this.ListenIncommingWebRequests, null); } } catch (Exception) { this.Shutdown(); } }
private void newClient_ProcessRequest(HttpWebServerRequest sender) { // Scrub the cache for old responses foreach (string key in new List<string>(CachedResponses.Keys)) { if (CachedResponses[key].Cache.TrashTime >= DateTime.Now) { CachedResponses.Remove(key); } } if (CachedResponses.ContainsKey(sender.ToString()) == true) { sender.Respond(CachedResponses[sender.ToString()]); } else if (ProcessRequest != null) { this.ProcessRequest(sender); } }