private void InitializeFiddler() { string pattern = @".*\/kcsapi\/(.*)\/(.*)"; Regex r = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled); Fiddler.FiddlerApplication.OnNotification += delegate(object sender, NotificationEventArgs oNEA) { Debug.Print("** NotifyUser: "******"** LogString: " + oLEA.LogString); }; Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS) { if (!r.IsMatch(oS.fullUrl)) { return; } NameValueCollection form = HttpUtility.ParseQueryString(oS.GetRequestBodyAsString()); string token = form["api_token"]; if (token != null && RequestBuilder.Token == null) { RequestBuilder.Initialize(oS); } else if (token != null && !RequestBuilder.Token.Equals(token)) { RequestBuilder.Initialize(oS); } oS.bBufferResponse = false; }; Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS) { if (!r.IsMatch(oS.fullUrl)) { return; } Match m = Regex.Match(oS.fullUrl, pattern); Debug.Print(String.Format("{0:hh:mm:ss.fff}\tEd session:\t{1}", DateTime.Now, oS.fullUrl)); try { string svdata; string json; JToken temp; switch (m.Groups[2].ToString()) { case "ship": if (m.Groups[1].ToString() == "api_get_master") { svdata = oS.GetResponseBodyAsString(); json = svdata.Substring(7); temp = JToken.Parse(json); OnShipSpecChangedEvent(new DataChangedEventArgs(temp["api_data"])); } else { svdata = oS.GetResponseBodyAsString(); json = svdata.Substring(7); temp = JToken.Parse(json); OnShipDataChangedEvent(new DataChangedEventArgs(temp["api_data"])); } break; case "ship2": svdata = oS.GetResponseBodyAsString(); json = svdata.Substring(7); temp = JToken.Parse(json); OnShipDataChangedEvent(new DataChangedEventArgs(temp["api_data"])); OnDeckDataChangedEvent(new DataChangedEventArgs(temp["api_data_deck"])); break; case "ship3": svdata = oS.GetResponseBodyAsString(); json = svdata.Substring(7); temp = JToken.Parse(json); OnShipDataChangedEvent(new DataChangedEventArgs(temp["api_data"]["api_ship_data"])); OnDeckDataChangedEvent(new DataChangedEventArgs(temp["api_data"]["api_deck_data"])); //OnSlotTypeChangedEvent(new DataChangedEventArgs(temp["api_data"]["api_slot_data"])); break; case "deck_port": svdata = oS.GetResponseBodyAsString(); json = svdata.Substring(7); temp = JToken.Parse(json); OnDeckDataChangedEvent(new DataChangedEventArgs(temp["api_data"])); break; case "deck": svdata = oS.GetResponseBodyAsString(); json = svdata.Substring(7); temp = JToken.Parse(json); OnDeckDataChangedEvent(new DataChangedEventArgs(temp["api_data"])); break; case "slotitem": if (m.Groups[1].ToString() == "api_get_master") { svdata = oS.GetResponseBodyAsString(); json = svdata.Substring(7); temp = JToken.Parse(json); OnItemSpecChangedEvent(new DataChangedEventArgs(temp["api_data"])); } else { svdata = oS.GetResponseBodyAsString(); json = svdata.Substring(7); temp = JToken.Parse(json); OnItemDataChangedEvent(new DataChangedEventArgs(temp["api_data"])); } break; case "questlist": svdata = oS.GetResponseBodyAsString(); json = svdata.Substring(7); temp = JToken.Parse(json); OnQuestDataChangedEvent(new DataChangedEventArgs(temp["api_data"])); break; case "stype": svdata = oS.GetResponseBodyAsString(); json = svdata.Substring(7); temp = JToken.Parse(json); OnShipTypeChangedEvent(new DataChangedEventArgs(temp["api_data"])); break; case "mapcell": OnScenarioStartEvent(null); break; case "logincheck": OnScenarioFinishEvent(null); break; case "next": naviEvent(oS, "next"); break; case "start": if (m.Groups[1].ToString() == "api_req_map") { naviEvent(oS, "start"); } break; case "battle": if (m.Groups[1].ToString() == "api_req_sortie") { battleEvent(oS, "day"); } else if (m.Groups[1].ToString() == "api_req_battle_midnight") { battleEvent(oS, "midnight"); } break; case "sp_midnight": battleEvent(oS, "sp_midnight"); break; case "battleresult": battleEvent(oS, "end"); break; case "ndock": svdata = oS.GetResponseBodyAsString(); json = svdata.Substring(7); temp = JToken.Parse(json); OnNDockDataChangedEvent(new DataChangedEventArgs(temp["api_data"])); break; default: break; } } catch (Exception exception) { Debug.Print(exception.ToString()); } }; Fiddler.CONFIG.IgnoreServerCertErrors = false; FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true); FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default; oFCSF = (oFCSF & ~FiddlerCoreStartupFlags.DecryptSSL); int iPort = 8877; Fiddler.FiddlerApplication.Startup(iPort, oFCSF); FiddlerApplication.Log.LogFormat("Created endpoint listening on port {0}", iPort); FiddlerApplication.Log.LogFormat("Starting with settings: [{0}]", oFCSF); FiddlerApplication.Log.LogFormat("Gateway: {0}", CONFIG.UpstreamGateway.ToString()); }