public void RouteSessionRequest(HttpListenerContext context) { string route = context.Request.RawUrl.ToLowerInvariant(); if (route.Length < 45) { Logger.LogWarning("Uri not long enough to contains session id"); throw new ArgumentNullException("Uri does not contain session id."); } string session_id = route.Substring(9, 36); if (!sessions.ContainsKey(session_id)) { Logger.LogWarning("Session '{0}' cannot be found.", session_id); context.ReturnException(new ArgumentException(string.Format("Session '{0}' cannot be found.", session_id))); return; } BaseSession session = sessions[session_id]; if (context.Request.HttpMethod == "DELETE") { session.KillProcess(); sessions.Remove(session_id); context.ReturnSuccess(); return; } session.ProcessRequest(context); }
private void Session_ProcessExited(object sender, EventArgs e) { BaseSession s = (BaseSession)sender; Logger.LogInfo("Session exited: {0}-{1}", s.Name, s.ID); sessions.Remove(s.ID); }