Flush() public méthode

Send the shit down the toilet
public Flush ( ) : void
Résultat void
Exemple #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);
            }
        }
Exemple #2
0
        private void tmrSpin_Tick(object sender, EventArgs e)
        {
            float movement = 11;

            rotation = (rotation + movement) % 360f;

            if (rotation % 2 == 0)
            {
                PacketHandler h = SMPInterface.Handler;
                h.SetOperationCode(SMPInterface.PacketTypes.PlayerPosition);

                double x = SMPInterface.PlayerX;
                double y = 126.0;
                double z = SMPInterface.PlayerZ;

                x += Math.Cos((rotation / 1.0) * Math.PI * 2.0) * 10.0;
                z += Math.Sin((rotation / 1.0) * Math.PI * 2.0) * 10.0;

                h.Write(SMPInterface.SwapByteOrder(x));
                h.Write(SMPInterface.SwapByteOrder(y));
                h.Write(SMPInterface.SwapByteOrder(y + 0.5));
                h.Write(SMPInterface.SwapByteOrder(z));
                h.Write(false);
                h.Flush();
            }
            else
            {
                float         x = rotation;
                float         y = 0f; // horizontal?
                PacketHandler h = SMPInterface.Handler;
                h.SetOperationCode(SMPInterface.PacketTypes.PlayerLook);
                h.Write(SMPInterface.SwapByteOrder(x));
                h.Write(SMPInterface.SwapByteOrder(y));
                h.Write(false);
                h.Flush();
            }
        }
Exemple #3
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;
            }
        }