Inheritance: System.Windows.Forms.Form
Ejemplo n.º 1
0
        /// <summary>
        /// Connect to a server with the given IPEndPoint
        /// </summary>
        public static bool Connect(string IP, string _Username, string _Password, string _SrvPassword)
        {
            System.Net.ServicePointManager.MaxServicePointIdleTime = 100000;

            con = new frmConsole();
            con.Show();

            SMPInterface.IsSMP = true;
            LoadPackets();

            Connection             = new TcpClient();
            Connection.SendTimeout = 500;
            Connection.NoDelay     = false;
            Connection.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, false);


            PacketResponder = new Thread(RespondWorker);
            PacketResponder.IsBackground = true;

            if (Auth(_Username, _Password))
            {
                Debug("Auth Successful\n");
                MineViewer.SMPPacketsCon.CF.Form = new frmSMPChat(delegate(string msg)
                {
                    SMPInterface.Handler.SetOperationCode(SMPInterface.PacketTypes.ChatMsg);
                    SMPInterface.Handler.Write(msg);
                });
                MineViewer.SMPPacketsCon.CF.Form.Show();
                Username    = _Username;
                SrvPassword = _SrvPassword;

                string[] split = IP.Split(":".ToCharArray());
                if (split.Length > 1)
                {
                    Connection.Connect(split[0], int.Parse(split[1]));
                }
                else
                {
                    Connection.Connect(IP, 25565);
                }

                Reader = new BinaryReader(Connection.GetStream());
                Writer = new BinaryWriter(Connection.GetStream());

                Handler = new PacketHandler(Writer);

                Handler.SetOperationCode(PacketTypes.Handshake);
                Handler.Write(Username);
                Handler.Flush();

                PacketResponder.Start();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Connect to a server with the given IPEndPoint
        /// </summary>
        public static bool Connect(string IP, string _Username, string _Password, string _SrvPassword)
        {
            System.Net.ServicePointManager.MaxServicePointIdleTime = 100000;

            con = new frmConsole();
            con.Show();

            SMPInterface.IsSMP = true;
            LoadPackets();

            Connection = new TcpClient();
            Connection.SendTimeout = 500;
            Connection.NoDelay = false;
            Connection.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, false);

            PacketResponder = new Thread(RespondWorker);
            PacketResponder.IsBackground = true;

            if (Auth(_Username, _Password))
            {
                Debug("Auth Successful\n");
                MineViewer.SMPPacketsCon.CF.Form = new frmSMPChat(delegate(string msg)
                {
                    SMPInterface.Handler.SetOperationCode(SMPInterface.PacketTypes.ChatMsg);
                    SMPInterface.Handler.Write(msg);
                });
                MineViewer.SMPPacketsCon.CF.Form.Show();
                Username = _Username;
                SrvPassword = _SrvPassword;

                string[] split = IP.Split(":".ToCharArray());
                if(split.Length > 1)
                    Connection.Connect(split[0], int.Parse(split[1]));
                else
                    Connection.Connect(IP, 25565);

                Reader = new BinaryReader(Connection.GetStream());
                Writer = new BinaryWriter(Connection.GetStream());

                Handler = new PacketHandler(Writer);

                Handler.SetOperationCode(PacketTypes.Handshake);
                Handler.Write(Username);
                Handler.Flush();

                PacketResponder.Start();
                return true;
            }
            else
            {
                return false;
            }
        }