public override void Initialize() { base.Initialize(); SessionFactory = new SessionFactory(this); Routes["/"]["GET"] = new ResourceResponder("twin-rc.index.html","text/html; charset=utf-8"); Routes["/ide"]["GET"] = new ResourceResponder("twin-rc.ide.html","text/html; charset=utf-8"); Routes["/ide.jar"]["GET"] = new ResourceResponder("twin-rc.twin-ide.jar","application/x-java-archive"); Routes["/status"]["GET"] = new JSONHandler(Sessions.Status); Routes["/session"]["POST"] = new JSONHandler(Sessions.Create); Routes["/session/:session"]["GET"] = new JSONHandler(Sessions.GetCapabilities); Routes["/session/:session"]["DELETE"] = new JSONHandler(Sessions.Delete); Routes["/session/:session/element/active"]["GET"] = new SessionHandler(Elements.GetFocused); Routes["/session/:session/element/active"]["POST"] = new SessionHandler(Elements.SetFocused); Routes["/session/:session/attachment"]["POST"] = new SessionHandler(Attachments.Create); Routes["/session/:session/attachment/:attachment"]["GET"] = new SessionHandler(Attachments.Get); Routes["/session/:session/attachment/:attachment"]["POST"] = new SessionHandler(Attachments.Update); Routes["/session/:session/attachment/:attachment"]["DELETE"] = new SessionHandler(Attachments.Delete); Routes["/session/:session/clipboard"]["POST"] = new SessionHandler(Clipboards.SetContent); Routes["/session/:session/clipboard"]["GET"] = new SessionHandler(Clipboards.GetContent); Routes["/session/:session/clipboard"]["DELETE"] = new SessionHandler(Clipboards.Clear); Element("/session/:session/element/:target"); Desktop("/session/:session/desktop"); if (Configuration.ContainsKey("grid.hub")) { Uri uri = new Uri(Configuration["grid.hub"]); Dictionary<string, string> hubConfiguration = new Dictionary<string, string>(); string configPrefix = "grid.configuration."; foreach (string key in Configuration.Keys) { if (!key.StartsWith(configPrefix)) continue; string shortKey = key.Substring(configPrefix.Length); hubConfiguration[shortKey] = Configuration[key]; } Hub = new GridHub(this, uri, hubConfiguration, Log); Hub.Connect(); } }
public Session(SessionFactory factory, Configuration config, Dictionary<string,object> sessionSetupInfo) { Factory = factory; Configuration = config; if (config.Capabilities.ContainsKey("sessionSetup.files") && Convert.ToBoolean(config.Capabilities["sessionSetup.files"])) sessionSetups.Add(new FileSessionSetup(config, sessionSetupInfo)); foreach (SessionSetup setup in sessionSetups) setup.Before(this); try { Process = Launch(config.LaunchStrategy); } catch (Exception e) { foreach (SessionSetup setup in sessionSetups) setup.After(this); throw e; } }