public static string GetRoomMessage(PocketProxy proxy, string token, string roomid)
        {
            HttpClientHandler handler = new HttpClientHandler();

            handler.Proxy    = new WebProxy(proxy.FullIP);
            handler.UseProxy = true;
            string repo = GetRoomMessage(handler, token, int.Parse(roomid));

            return(repo);
        }
        //获取直播信息,废弃不用了
        public static string GetLive(PocketProxy proxy, UserInfo user, long lasttime)
        {
            HttpClientHandler handler = new HttpClientHandler();

            if (proxy != null)
            {
                handler.UseProxy = proxy.UseProxy;
                if (proxy.UseProxy)
                {
                    handler.Proxy = new WebProxy(proxy.FullIP);
                }
            }
            string repo = GetLive(handler, user.PocketToken, lasttime);

            return(repo);
        }
Esempio n. 3
0
        private void btn_proxyapply_Click(object sender, EventArgs e)
        {
            if (txt_proxy.Text == "")
            {
                MessageBox.Show("即将进行代理关闭操作,如果是误操作,请自行再次查找代理");
                PocketPlugins.Proxy = null;
                foreach (string key in PocketPlugins.RunTimeCfg.Keys)
                {
                    ListenRunTimeConfig cfg = (ListenRunTimeConfig)PocketPlugins.RunTimeCfg[key];
                    cfg.Proxy = null;
                }
                MessageBox.Show("更换完成,请留意监听情况和酷Q日志");
                return;
            }

            if (!txt_proxy.Text.Contains(":"))
            {
                MessageBox.Show("大兄弟,不知道用别乱折腾了,欢迎捐助!");
                return;
            }
            string      fullProxy = txt_proxy.Text;
            PocketProxy proxy     = new PocketProxy();

            proxy.FullIP = fullProxy;
            string[] info = fullProxy.Split(':');
            proxy.IP       = info[0];
            proxy.Port     = info[1];
            proxy.UseProxy = true;

            if (roomid == "")
            {
                MessageBox.Show("由于有自动化测试需要,请先随机查找一个成员后再应用", "错误");
                return;
            }
            string json = Common.GetRoomMessage(proxy, PocketPlugins.User.PocketToken, roomid);

            if (json == "")
            {
                MessageBox.Show("代理不可用,换一个吧", "错误");
            }
            try
            {
                JObject obj = JObject.Parse(json);
                if ((int)obj["status"] != 200)
                {
                    MessageBox.Show("可能有问题,建议更换");
                }
                else
                {
                    MessageBox.Show("代理可用,即将开始更换代理");
                    PocketPlugins.Proxy = proxy;
                    foreach (string key in PocketPlugins.RunTimeCfg.Keys)
                    {
                        ListenRunTimeConfig cfg = (ListenRunTimeConfig)PocketPlugins.RunTimeCfg[key];
                        cfg.Proxy = proxy;
                    }
                    MessageBox.Show("更换完成,请留意监听情况和酷Q日志");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("代理不可用,换一个吧", "错误");
            }
        }