예제 #1
0
파일: FormMain.cs 프로젝트: lscyane/KCBr
        void _httProxy_BeforeRequest(HTTProxy.SessionInfo info)
        {
            Debug.WriteLine("BeforeRequest:" + info.Uri);


            //ゲーム開始時のトークンと時間を覚えておく
            if (info.Uri.ToString().Contains("mainD2.swf"))
            {
                //別スレッドから呼ばれるのでUIスレッドに処理を投げる
                BeginInvoke((MethodInvoker)(() => adjustFlashPosition()));

                if (_watchSession)
                    _logFirstSession(info.Uri.ToString());
            }


            /* 艦これAPI以外へのアクセスは全部無視する
             */
            if (!info.Uri.PathAndQuery.StartsWith("/kcsapi/"))
            {
                info.Ignore = true;
                return;
            }

            switch (info.Uri.PathAndQuery)
            {
                case "/kcsapi/api_req_map/next":
                    CheckShipStatus(info);
                    return;
            }

        }
예제 #2
0
파일: FormMain.cs 프로젝트: lscyane/KCBr
        void _httProxy_AfterSessionCompleted(HTTProxy.SessionInfo info)
        {
            //MIME形式を見る
            if (info.Response.ContentType != "text/plain")
            {
                Debug.WriteLine("MIMEType is not text/plain. return");
                return;
            }


            var httproxySession = new HTTProxySessionData(info);

            if (_watchSession)
            {
                var q = httproxySession.QueryParam;
                if (q.ContainsKey("api_token"))
                    _updateAPIToken(q["api_token"]);
            }

            _processor.Add(httproxySession);
        }
예제 #3
0
파일: FormMain.cs 프로젝트: lscyane/KCBr
        /// <summary>
        /// 必要ならば進撃を中断させる。
        /// </summary>
        /// <param name="oSession"></param>
        void CheckShipStatus(HTTProxy.SessionInfo info)
        {
            if (_statusManager.CheckFleetCondition())
                return;

            //処理失敗のレスポンスJSONを作って、サーバにリクエストを飛ばさずflashへ食わせる
            string ret_json = "svdata={\"api_result\":0,\"api_result_msg\":\"aborted\"}";
            info.Response.ContentString = ret_json;
            info.BypassServerRequest = true;
            UpdateStatus("進撃を中止しました");
        }
예제 #4
0
파일: FormMain.cs 프로젝트: lscyane/KCBr
//        string _fiddlerOverrideGateway;

        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="bPortable">設定を保存しない時true</param>
        public FormMain(bool bPortable)
        {
            InitializeComponent();
            IntPtr ptr = Handle;
            _bPortable = bPortable;

            MouseWheel += FormMain_MouseWheel;
            MouseEnter += FormMain_MouseEnter;
            _sysProxy = System.Net.WebRequest.DefaultWebProxy;

            var asm = System.Reflection.Assembly.GetExecutingAssembly();
            imageListSlotItemType.Images.AddStrip(new Bitmap(
                asm.GetManifestResourceStream("KCB2.SlotItemsSmallIcon.bmp")));
            imageListSlotItemType.TransparentColor = Color.FromArgb(255, 0, 255);
            deckMemberList.SlotItemIconImageList = imageListSlotItemType;

#if RESTORE_VOLUME
            ///起動時の音量設定を覚えておく
            using (var mixer = new MixerAPI())
            {
                bootVol = mixer.Volume;
                bootMute = mixer.Mute;
            }
#endif

            // WebRequestの同時処理数を引き上げる
            if (ServicePointManager.DefaultConnectionLimit < 20)
            {
                Debug.WriteLine(string.Format("ServicePointManager.DefaultConnectionLimit {0} -> 20",
                    ServicePointManager.DefaultConnectionLimit));
                ServicePointManager.DefaultConnectionLimit = 20;
            }

            //スレッドプール数を増やす
            int minWorkerThread, minCompletionPortThread;
            ThreadPool.GetMinThreads(out minWorkerThread, out minCompletionPortThread);
            Debug.WriteLine(string.Format("ManagedThread minWorkder:{0} minCompPortThread:{1}",
                minWorkerThread, minCompletionPortThread));
            if (minWorkerThread < 20)
            {
                Debug.WriteLine(string.Format("minWorkerThread {0} -> 20", minWorkerThread));
                ThreadPool.SetMinThreads(20, minCompletionPortThread);
            }


            _httProxy = new HTTProxy();
            _httProxy.BeforeRequest += new HTTProxy.HTTProxyCallbackHandler(_httProxy_BeforeRequest);
            _httProxy.AfterSessionCompleted += new HTTProxy.HTTProxyCallbackHandler(_httProxy_AfterSessionCompleted);

            ///過去の設定を引っ張ってる場合。
            if (Properties.Settings.Default.ProxyPort <= 0)
                Properties.Settings.Default.ProxyPort = 8088;

            _gsWrapper = new GSpread.SpreadSheetWrapper();

            if (!_httProxy.Start(Properties.Settings.Default.ProxyPort))
                MessageBox.Show("HttpListenerの起動に失敗しました。情報は取得されません。\n設定を確認してください");

            else
                UpdateProxyConfiguration();


            _logManager = new LogManager.LogManager(this);
//            _fiddlerOverrideGateway = Properties.Settings.Default.FiddlerOverrideGateway;

#if !DEBUG
            if (Properties.Settings.Default.UseDevMenu)
#endif
            {
                _watchSession = true;
                _logLastJSON = new RingBuffer<JSONData>(Properties.Settings.Default.SkipbackJSON+1);
            }


            deckMemberList.UpdateDeckStatus = UpdateDeckConditionTime;

            ///縦横切替を使うかどうか
            switchViewModeToolStripMenuItem.Visible = false;

            setLogStore();
        }
예제 #5
0
파일: SessionData.cs 프로젝트: lscyane/KCBr
        public HTTProxySessionData(HTTProxy.SessionInfo info)
        {
            RequestBody = info.Request.String;
            ResponseBody = info.Response.ContentString;
            PathQuery = info.Uri.PathAndQuery;
            ResponseMimeType = info.Response.ContentType;

            SessionType = "HTTProxy";
        }