예제 #1
0
        private void PingThread()
        {
            Vars.Set("WF_PingDelay", 15000);
            while (true)
            {
                if (Automate)
                {
                    if (Connected)
                    {
                        if (!pingrecv) //didn't receive last ping (15 seconds) disconnect
                        {
                            if (this.OnDisconnect != null)
                            {
                                this.OnDisconnect(this);
                            }
                        }
                        pingrecv = false;
                        LastPing = DateTime.Now;
                        this.Send(new Packet("Ping"));
                    }
                }
                else
                {
                    Thread.Sleep(2000);
                }

                Thread.Sleep(Vars.GetI("WF_PingDelay"));
            }
        }
예제 #2
0
        private void BtnSend_Click(object sender, EventArgs e)
        {
            LastSent     = TxtSend.Text;
            TxtSend.Text = "";
            SentMem.Add(LastSent);



            if (LastSent.StartsWith("/"))
            {
                int endindex = LastSent.IndexOf(" ");
                if (endindex == -1)
                {
                    endindex = LastSent.Length;
                }

                string cmd = LastSent.Substring(1, endindex - 1);
                cmd = cmd.ToLower();
                string args = LastSent.Replace("/" + cmd, "").Trim();
                if (cmd == "connect")
                {
                    CS.SysLog("Attempting to connect to '" + args + "'.");
                    LblStatus.Text = "Status: Connecting";
                    if (C.Connect(args, Vars.GetI("Hostport"), true))
                    {
                        LblStatus.Text = "Status: Connected";
                        C.Send(new Packet("Name"));
                    }
                }
                else
                {
                    C.Send(new Packet(cmd, args));
                }
                //Cmd.Process(cmd, args);
            }
            else
            {
                LastSent = "/Msg " + LastSent;

                int endindex = LastSent.IndexOf(" ");
                if (endindex == -1)
                {
                    endindex = LastSent.Length;
                }

                string cmd  = LastSent.Substring(1, endindex - 1);
                string args = LastSent.Replace("/" + cmd, "").Trim();


                if (C.Connected)
                {
                    C.Send(new Packet(cmd, args));

                    //TryChat(string.Format("[{0}] {1}", username, args));
                }
                else
                {
                    TryChat("You are not connected to any servers.");
                }
            }
        }