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(); } }
protected override void finish_field(string field_name, JSONHandler field_handler) { }
public override void write_fields_as_json(JSONHandler handler) { write_fields_as_json(handler, false); }
public override void write_fields_as_json(JSONHandler handler, bool partial_allowed) { base.write_fields_as_json(handler, partial_allowed); }
public virtual void write_fields_as_json(JSONHandler handler) { write_fields_as_json(handler, false); }
public override void write_fields_as_json(JSONHandler handler, bool partial_allowed) { base.write_fields_as_json(handler, partial_allowed); Debug.Assert(partial_allowed || flagHasCommandType); if (flagHasCommandType) { handler.start_pair("CommandType"); switch (storeCommandType) { case TypeCommandType.CommandType_AdjustVolume: handler.string_value("AdjustVolume"); break; case TypeCommandType.CommandType_SetVolume: handler.string_value("SetVolume"); break; case TypeCommandType.CommandType_MuteSound: handler.string_value("MuteSound"); break; case TypeCommandType.CommandType_UnMuteSound: handler.string_value("UnMuteSound"); break; default: Debug.Assert(false); break; } } if (flagHasVolumeValue) { handler.start_pair("VolumeValue"); if (textStoreVolumeValue != "") { handler.number_value(textStoreVolumeValue); } else if (((double)(long)storeVolumeValue) == storeVolumeValue) { handler.number_value((long)storeVolumeValue); } else { handler.number_value(storeVolumeValue); } } if (flagHasVolumeLevel) { handler.start_pair("VolumeLevel"); if (textStoreVolumeLevel != "") { handler.number_value(textStoreVolumeLevel); } else if (((double)(long)storeVolumeLevel) == storeVolumeLevel) { handler.number_value((long)storeVolumeLevel); } else { handler.number_value(storeVolumeLevel); } } if (flagHasVolumeDelta) { handler.start_pair("VolumeDelta"); if (textStoreVolumeDelta != "") { handler.number_value(textStoreVolumeDelta); } else if (((double)(long)storeVolumeDelta) == storeVolumeDelta) { handler.number_value((long)storeVolumeDelta); } else { handler.number_value(storeVolumeDelta); } } }
public override void write_fields_as_json(JSONHandler handler, bool partial_allowed) { base.write_fields_as_json(handler, partial_allowed); handler.pair("TerrierUploadCommandKind", getTerrierUploadCommandKind()); }
public override void write_as_json(JSONHandler handler) { handler.start_object(); write_fields_as_json(handler); handler.finish_object(); }
public JSONResponder(JSONHandler handler) : base(null) { this.handler = handler; }