示例#1
0
        public void Login(LoginParams loginParams)
        {
            this.loginParams = loginParams;

            try
            {
                tcpClient = new TcpClient(loginParams.ServerHost, loginParams.ServerPort)
                {
                    ReceiveBufferSize = 1024 * 1024
                };
                SendPacket(new C00PacketHandshake(47, loginParams.ServerHost, loginParams.ServerPort, 2));
                SendPacket(new C00PacketLogin(loginParams.Username));

                netHandler = new NetHandler(this);
                receiver   = new PacketReceiver(this, netHandler);
                receiver.StartReceiver();
            }
            catch (Exception e)
            {
                MessageBox.Show("Could not connect: " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        public bool Login(LoginParams loginParams)
        {
            this.loginParams = loginParams;

            try
            {
                tcpClient = new TcpClient(loginParams.ServerHost, loginParams.ServerPort)
                {
                    ReceiveBufferSize = 1024 * 1024
                };
                SendPacket(new C00PacketHandshake(47, loginParams.ServerHost, loginParams.ServerPort, 2));
                SendPacket(new C00PacketLogin(loginParams.Username));

                netHandler = new NetHandler(this);
                receiver   = new PacketReceiver(this, netHandler);
                receiver.StartReceiver();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }