示例#1
0
 private void FormShowCookiesLoad(object sender, EventArgs e)
 {
     textBoxCookies.Text = CookiesManager.Obtain("www.neverlands.ru");
     CopyToClipboard();
 }
示例#2
0
        private static void RoomAsync(object stateInfo)
        {
            while (!_doStop)
            {
                if (AppVars.DoShowWalkers)
                {
                    try
                    {
                        IdleManager.AddActivity();
                        var wr = (HttpWebRequest)WebRequest.Create("http://neverlands.ru/ch.php?lo=1&");
                        wr.Method = "GET";
                        wr.Proxy  = AppVars.LocalProxy;
                        var cookies = CookiesManager.Obtain("www.neverlands.ru");
                        wr.Headers.Add("Cookie", cookies);
                        var resp      = wr.GetResponse();
                        var webstream = resp.GetResponseStream();
                        if (webstream != null)
                        {
                            using (var reader = new StreamReader(webstream, AppVars.Codepage))
                            {
                                var responseFromServer = reader.ReadToEnd();
                                {
                                    var ssum  = HelperStrings.SubString(responseFromServer, "</b></font></a> [ ", " ]");
                                    var slist = HelperStrings.SubString(responseFromServer, "var ChatListU = new Array(",
                                                                        ");");
                                    var newRoom = $"[{ssum}] {slist}";
                                    if (string.Compare(newRoom, _oldRoom, StringComparison.Ordinal) != 0)
                                    {
                                        Process(responseFromServer);
                                        _oldRoom = newRoom;

                                        try
                                        {
                                            if (AppVars.MainForm != null)
                                            {
                                                AppVars.MainForm.BeginInvoke(
                                                    new ReloadChPhpInvokeDelegate(AppVars.MainForm.ReloadChPhpInvoke),
                                                    new object[] {});
                                            }
                                        }
                                        catch (InvalidOperationException)
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (WebException)
                    {
                    }
                    catch (IOException)
                    {
                    }
                    finally
                    {
                        IdleManager.RemoveActivity();
                    }
                }

                Event.WaitOne(100, false);
            }
        }
示例#3
0
        private static void WaitForTurnAsync(object stateInfo)
        {
            var timeStart   = DateTime.Now;
            int lastSeconds = -1;

            while (AppVars.AutoRefresh)
            {
                var timeDiff = DateTime.Now.Subtract(timeStart);
                if ((timeDiff.Seconds % 30) == 0 && (lastSeconds != timeDiff.Seconds))
                {
                    lastSeconds = timeDiff.Seconds;
                    if (AppVars.MainForm != null)
                    {
                        AppVars.MainForm.WriteChatMsgSafe(
                            $"Ожидаем хода противника... <b>{timeDiff.Minutes}:{timeDiff.Seconds:00}</b>");
                    }
                }

                var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.neverlands.ru/main.php");
                httpWebRequest.Method = "GET";
                httpWebRequest.Proxy  = AppVars.LocalProxy;
                var cookies = CookiesManager.Obtain("www.neverlands.ru");
                httpWebRequest.Headers.Add("Cookie", cookies);
                string html = null;
                try
                {
                    IdleManager.AddActivity();
                    var resp      = httpWebRequest.GetResponse();
                    var webstream = resp.GetResponseStream();
                    if (webstream != null)
                    {
                        var reader = new StreamReader(webstream, AppVars.Codepage);
                        html = reader.ReadToEnd();
                    }
                }
                catch
                {
                    html = null;
                }
                finally
                {
                    IdleManager.RemoveActivity();
                }

                if (string.IsNullOrEmpty(html))
                {
                    break;
                }

                if (!AreWaitingForTurn(html))
                {
                    break;
                }
            }

            if (AppVars.AutoRefresh && (AppVars.MainForm != null))
            {
                try
                {
                    if (AppVars.MainForm != null)
                    {
                        AppVars.MainForm.BeginInvoke(
                            new ReloadMainPhpInvokeDelegate(AppVars.MainForm.ReloadMainPhpInvoke),
                            new object[] { });
                    }
                }
                catch (InvalidOperationException)
                {
                }
            }

            AppVars.ThreadWaitForTurn = null;
        }