Sign in to follow this  
Landi20

network problem

Recommended Posts

Landi20    257

i have this error InvokeRequired does not exist in corrent contest and name invoke does existe in corrent context

this is my function

i using xna with neoforce

i making my game using neoforce windows

my code

private void ProcessComplete(Headers header, ErrorCodes error)
        {
            if (InvokeRequired)
            {
                Invoke(new ProcessCompleteDel(ProcessComplete), header, error);
                return;
            }

            if (header != Headers.Login)
                return;

            if (error == ErrorCodes.Success)
            {
               // MessageBox.Show(string.Format("Welcome, {0}", txtUsername.Text), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //world ola =new world

               // Hide();
            }
            else
            {
                string msg = "";

                switch (error)
                {
                    case ErrorCodes.InvalidLogin:
                        msg = "The username\\password combo does not match records.";
                        break;
                    case ErrorCodes.Error:
                        msg = "An unknown error has ocurred. Please try again later";
                        break;
                }

               // MessageBox.Show(msg, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

Share this post


Link to post
Share on other sites
hplus0603    11347

This is not a network problem. It's a problem that the library you're using doesn't export the function you're trying to use. That's specific to the compiler and library (assembly) setup you're using.

Share this post


Link to post
Share on other sites
Landi20    257

how i solve the problem??

i put comment the error and now give this error

layout.cs

cliente project

/*..........................*/

public MainWindow(Manager manager): base(manager)
    {
        cliente = new LoginClient();
      greenbg = Manager.Content.Load<Texture2D>("Content\\Images\\Green");
      defaultbg = Manager.Content.Load<Texture2D>("Content\\Images\\Default");
      (Manager.Game as Application).BackgroundImage = defaultbg;     

      InitControls();
     
        
    
      } 
     private void ProcessComplete(Headers header,ErrorCodes Erro){
        /* if (InvokeRequired) {
           Invoke(new ProcessesCompleteDel(ProcessComplete), header, Erro);
            return;
         */
      //   } 
      if (header != Headers.Login) {
             return;
         } if (Erro == ErrorCodes.Sucess)
         {

             TomShane.Neoforce.Controls.MessageBox.Show(Manager, TomShane.Neoforce.Controls.MessageBox.MessageBoxType.CANCEL, "Wecome,{0}" + Username, "");
             server ola = new server(Manager, txusername.Text.Trim());
             //Close();
             // this.Hide();
             //server ola = new server(Manager, txusername.Text.Trim(),txpassword.Text.Trim());
             ola.Init();
             ola.StayOnTop = true;

             //Manager.Add(ola);
             ola.Visible = false;
             //ola.Width = 800;
             //ola.Height = 600;
             ola.CloseButtonVisible = false;
             ola.Center();
             ola.Movable = false;
             ola.Shadow = false;
             ola.Show();


             txusername.Hide();
             txpassword.Hide();
             lbusername.Hide();
             lbpassword.Hide();
             btnApply.Hide();
             btnExit.Hide();

         }
         else
         {
             string msg = "";
             switch (Erro) { 
                 case ErrorCodes.InvalidLogin:
                     msg = "username \\Password is incorrect";
                     break;
                 case ErrorCodes.Error:
                     msg = "ERROR";// with server offline your online wrong passwor your not give same error "ERROR"
                     break;
             }
             TomShane.Neoforce.Controls.MessageBox.Show(Manager, TomShane.Neoforce.Controls.MessageBox.MessageBoxType.ERROR, "" + msg, "");
       
        }
     }

cliente logic.cs

void btnApply_Click(object sender, Controls.EventArgs e)
    {
        String user = txusername.Text.Trim();
       // System.Console.WriteLine(user);
        String userPassword = txpassword.Text.Trim();
      //  System.Console.WriteLine(userPassword);
        if (txusername.Text.Trim().Equals(String.Empty) || txpassword.Text.Trim().Equals(String.Empty))
      {
            TomShane.Neoforce.Controls.MessageBox.Show(Manager, TomShane.Neoforce.Controls.MessageBox.MessageBoxType.ERROR, "Username Ou Password is empty", "");

        }
      else { 
        //cliente.GetStream().BeginRead(readBuffer, 0, BUFFER_SIZE, StreamReceived, null);
            cliente.Login(user,userPassword, ProcessComplete);
            
        }

logincliente.cs cliente

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace TomShane.Neoforce.Central.Code
{
    public delegate void ProcessesCompleteDel(Headers header,ErrorCodes errorcode);
    internal struct LoginArgs {
        public string Username;
        public string Password;
        public Headers Header;
        public ProcessesCompleteDel Callback;
        public LoginArgs(Headers header, string username, string password, ProcessesCompleteDel callback) {
            Username = username;
            Password = password;
            Header = header;
            Callback = callback;

        }
    }

   public class LoginClient
    {
       private byte[] buffer = new byte[512];
public LoginClient(){}
    
       public void Login(string username,string password, ProcessesCompleteDel callback){
           LoginArgs args = new LoginArgs(Headers.Login,username,password,callback);
           ThreadPool.QueueUserWorkItem(new WaitCallback(process),args);
    }
    private void process(object o)
    {
        LoginArgs args = (LoginArgs)o;
        Socket sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        try {
            sck.Connect(serverinfo.Server, serverinfo.port);
            PacketWriter pw = new PacketWriter();
            pw.Write((ushort)args.Header);
            pw.Write(args.Username);
            pw.Write(args.Password);
            byte[] data = pw.GetBytes();
            sck.Send(data, 0, data.Length, SocketFlags.None);
            sck.ReceiveTimeout = 8000;
            sck.Receive(buffer, 0, buffer.Length, SocketFlags.None);
            PacKetReader pr = new PacKetReader(buffer);
            Headers header = (Headers)pr.ReadUInt16();
            ErrorCodes error = (ErrorCodes)pr.ReadUInt16();
            args.Callback(header, error);
        }
        catch {
            args.Callback(args.Header, ErrorCodes.Error);
        }
        finally {
            sck.Close();

        }
    }

   }
 

    }

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.Serialization.Formatters.Binary;

public class PacketWriter : BinaryWriter
{
    private MemoryStream _ms;
    private BinaryFormatter _bf;
    public PacketWriter()
        : base()
    {
        _ms = new MemoryStream();
        _bf = new BinaryFormatter();
        OutStream = _ms;
    }
    public void Write(Image image)
    {
        var ms = new MemoryStream();
        image.Save(ms, ImageFormat.Png);
        ms.Close();
        byte[] imageBytes = ms.ToArray();
        Write(imageBytes.Length);
        Write(imageBytes);
    }
    public void WriteT(object obj) {

        _bf.Serialize(_ms, obj);
    }
    public byte[] GetBytes() {
        Close();
        byte[] data = _ms.ToArray();
        return data;
    }
}

public class PacKetReader : BinaryReader
{
    private BinaryFormatter _bf;
    public PacKetReader(byte[] data)
        :base(new MemoryStream(data)){
    _bf = new BinaryFormatter();

    }
   public Image ReadImage(){
       int len = ReadInt32();
       byte[] bytes = ReadBytes(len);
       Image img;
       using (MemoryStream ms = new MemoryStream(bytes)) {
           img = Image.FromStream(ms);

       }
       return img;
   }
   public T ReadObject<T>() {
       return (T)_bf.Deserialize(BaseStream);
   }
}

using System;
public enum Headers : ushort
{
    Login
}
public enum ErrorCodes : ushort { 
Sucess,
    Exists,
    InvalidLogin,
    Error

}

public enum Rank : ushort
{
    Administrador,
    Moderador,
    Vip,
    player,
    Banned

}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TomShane.Neoforce.Central.Code
{
 internal class serverinfo
    {
     public const string Server = "127.0.0.1";
     public const int port = 1234;

    }
}

now the server project

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySql.Data.MySqlClient;
using System.Windows.Forms;
using System.Security.Cryptography;
using System.Security;
using System.Net.Sockets;
using System.IO;
namespace TomShane.Neoforce.Central.Code
{
    class Login
    {
       // private DBConnect dbConnect;
      //  public Socket c_scoket;
        public int id_user;
     //   public uint dwsessions;
        String username;
        String password;
        public int tipo;
      //  public bool bIsBusy;
        public byte[] remains = null;
       // public NetworkStream n_stream;
      //  BinaryWriter Writer { get; set; }
       // BinaryReader Reader { get; set; }
       
        public int Id
        {

            get { return id_user; }
            set { id_user = value; }
        }
        public String Username
        {
            get { return username; }
            set { username = value; }
        }
        public String Password
        {
            get { return password; }
            set { password = value; }
        }
        public int Tipo
        {
            get { return tipo; }
            set { tipo = value; }
        }
       /* private Login(Socket s)
        {
           //;
           this.c_scoket = s;
           this.id_user = 1;
           this.dwsessions=(uint)new Random().Next(0,ushort.MaxValue*5);
           this.bIsBusy = false;
            this.n_stream= new NetworkStream(s);
            this.Writer = new BinaryWriter(n_stream);
            this.Reader = new BinaryReader(n_stream);
            
       }
        */

       /* public void Handlepack() {
            Packet pak;
            while ((pak = Recieve()) != null)
            {
                switch (pak._PacketTypeLogin)
                {
                  
                }
            }
        }
        * */
      /*  Packet recive() { 
        
        
        }
       * */
        public int nivel(string username){
            try
            {
                MySqlConnection con = new MySqlConnection("host=localhost;user=root;database=gest");

                MySqlCommand cmdo = new MySqlCommand("SELECT tipo FROM user WHERE Username= '" + username + "'");
                cmdo.Connection = con;
                con.Open();
                object Tipo = cmdo.ExecuteScalar();
                if (Tipo != null && Tipo != DBNull.Value)
                {
                    tipo = System.Convert.ToInt32(Tipo);

                    con.Close();
                    return tipo; 
                    
                   
                } else{
                   
                    
                     con.Close();
                     return -1;
                }
                    

               




            }
            catch (MySqlException)
            {
                
                return 0;
              
            }
        }
        
                        
         public  string loginretrive(string username, string password) 
        {
               
            try
            {

               

                MySqlConnection con = new MySqlConnection("host=localhost;user=root;database=gest");

                MySqlCommand cmd = new MySqlCommand("SELECT password FROM user WHERE Username  ='" + username + "'");
                cmd.Connection = con;
                con.Open();
                object hello = cmd.ExecuteScalar();
                if (hello == null)
                {
                   
                    return null;
                }
                else
                {
                    string Password = hello.ToString();

                    String userPassword = password; // que hizo el usuario escribe?                
                   // con.Close();
                    if (Login.Equals(Password, password))
                    {
                        
                      
                        return "YES";
                       // return true;
                        // corregir!
                       /* MySqlCommand cmdo = new MySqlCommand("SELECT w70tg_user_usergroup_map.group_id FROM w70tg_users INNER JOIN w70tg_user_usergroup_map on w70tg_user_usergroup_map.user_id=w70tg_users.id  WHERE username  = '" + username + "'");
                        cmdo.Connection = con;
                        con.Open();
                        object Tipo = cmdo.ExecuteScalar();
                        if (Tipo != null && Tipo != DBNull.Value)
                        {
                           tipo=System.Convert.ToInt32(Tipo);
                          
                            switch (tipo)
                            {
                                case 8:
                                    //string tipo2 = System.Convert.ToString(tipo);
                                   // return tipo;
                                MessageBox.Show("ADMINISTRADOR");
                                    break;
                                case 11:
                                    MessageBox.Show("GAME MASTER");
                                    break;
                                case 10:
                                    MessageBox.Show("Moderador");
                                    break;
                                case 3:
                                    MessageBox.Show("VIP");
                                    break;
                                case 2:
                                    MessageBox.Show("Membro");
                                    break;
                                case 1:
                                    MessageBox.Show("O Utilizador foi banido\n Contacte a Equipa atravez do suporte para saber a razão pelo qual foi banido(a)");
                                    break;
                            }
                        
                        }
                        * */
                    }
                    else
                    {
                       
                        con.Close();
                        return "NO";

                    }
                   
                }
            }
            catch (MySqlException msqle)
            {
                
                return msqle.Message;
            }
        }
    }
}

using System.Text;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.Serialization.Formatters.Binary;

public class PacketWriter : BinaryWriter
{
    private MemoryStream _ms;
    private BinaryFormatter _bf;
    public PacketWriter()
        : base()
    {
        _ms = new MemoryStream();
        _bf = new BinaryFormatter();
        OutStream = _ms;
    }
    public void Write(Image image)
    {
        var ms = new MemoryStream();
        image.Save(ms, ImageFormat.Png);
        ms.Close();
        byte[] imageBytes = ms.ToArray();
        Write(imageBytes.Length);
        Write(imageBytes);
    }
    public void WriteT(object obj) {

        _bf.Serialize(_ms, obj);
    }
    public byte[] GetBytes() {
        Close();
        byte[] data = _ms.ToArray();
        return data;
    }
}

public class PacKetReader : BinaryReader
{
    private BinaryFormatter _bf;
    public PacKetReader(byte[] data)
        :base(new MemoryStream(data)){
    _bf = new BinaryFormatter();

    }
   public Image ReadImage(){
       int len = ReadInt32();
       byte[] bytes = ReadBytes(len);
       Image img;
       using (MemoryStream ms = new MemoryStream(bytes)) {
           img = Image.FromStream(ms);

       }
       return img;
   }
   public T ReadObject<T>() {
       return (T)_bf.Deserialize(BaseStream);
   }
}

using System;
public enum Headers : ushort
{
    Login
}
public enum ErrorCodes : ushort { 
Sucess,
    Exists,
    InvalidLogin,
    Error

}

public enum Rank : ushort
{
    Administrador,
    Moderador,
    Vip,
    player,
    Banned

}
namespace TomShane.Neoforce.Central.Code
{
    public delegate void SocketAcceptedEventHandler(object sender,Socket e);
     class Listener
    {
        private Socket socket;
        public bool Running
        {
            get;
           private set;
        }
        public event SocketAcceptedEventHandler Accepted;

        public Listener() { 
        
        }
        public void start(int port) {
            if (socket != null) {
                
                Running = true;
                socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                socket.Bind(new IPEndPoint(IPAddress.Any, port));
               
                socket.Listen(100);
                socket.BeginAccept(callback,null);
                return;
            }
            
        }
        public void stop() {

            if (socket == null) {
               
                Running = false;
                socket.Close();
                return;
            }
        }
        private void callback(IAsyncResult ar) { 
        try{
            Socket acc = socket.EndAccept(ar);
            if(Accepted!=null){
                Accepted(this,acc);
        }
        }
            catch(Exception){
            
            
            }
            if(Running){
            socket.BeginAccept(callback,null);
            }
            }
        
     

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
//using System.Windows.Forms;
//using TomShane.Neoforce.Central.Code;

namespace TomShane.Neoforce.Central.Code
{
     class Client
    {
         private Socket socket;
         private byte[]buffer=new byte[512];
         public Client(Socket sck) {
             socket = sck;
             socket.ReceiveTimeout = 5000;

         
         
         }
         public byte[] Receive() {
             SocketError erro;
             int res = socket.Receive(buffer, 0, buffer.Length, SocketFlags.None, out erro);
             if (erro != SocketError.Success) {
                 return null;
             }
             return buffer;
         
         }
         public void Send(byte[] data) {

             SocketError erro;
             socket.Send(data, 0, data.Length, SocketFlags.None, out erro);
         }
         public void Close() {
             socket.Close();
             buffer = null;
         
         }
     
    }
}

using TomShane.Neoforce.Controls;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using TomShane.Neoforce.Central.Code;
using System.Net;
using System.Net.Sockets;
using System.IO;


////////////////////////////////////////////////////////////////////////////

#endregion

namespace TomShane.Neoforce.Central
{
  public partial class MainWindow: Window
  {
  
      
 //Server  ola= new Server(1490);

    #region //// Fields ////////////
      public const int PORT = 1234;
    ////////////////////////////////////////////////////////////////////////////       
    private Texture2D defaultbg;
    private Texture2D greenbg;
    
    private SideBar sidebar = null;

    private SideBarPanel pnlRes = null;
  
    private Button btnApply = null;
    private Button btnExit = null;

   private SideBarPanel pnlTasks = null;
   
    private Button[] btnTasks = null;

    private SideBarPanel pnlSkin = null;
               
        
    private SideBarPanel pnlStats = null;
    public Label lblObjects = null;
    public Label lblAvgFps = null;    
    public Label lblFps = null;    
    ////////////////////////////////////////////////////////////////////////////
    
    #endregion

    #region //// Constructors //////

    ////////////////////////////////////////////////////////////////////////////
    public MainWindow(Manager manager): base(manager)
    {
      greenbg = Manager.Content.Load<Texture2D>("Content\\Images\\Green");
      defaultbg = Manager.Content.Load<Texture2D>("Content\\Images\\Default");
      (Manager.Game as Application).BackgroundImage = defaultbg;
     // Login login=new Login();
     // login.loginretrive(username,password);
      InitControls();
     
    }
    static void listener_Accepted(object sender, System.Net.Sockets.Socket e) {
        Client client = new Client(e);
        byte[] data = client.Receive();
        if (data == null) {
            client.Close();
            return;
        }
        PacKetReader pr = new PacKetReader(data);
        Headers header=(Headers)pr.ReadUInt16();
        switch (header) {
            case Headers.Login: {
                Logger(client, pr.ReadString(), pr.ReadString());
            }break;

        } 
        client.Close();


    }
    static void SendPacktWriter(Client client,PacketWriter pw) {
        byte[] data = pw.GetBytes();
        client.Send(data);
}
    static void Logger(Client client, string username, string password)
    {
        Login login = new Login();
        PacketWriter pw = new PacketWriter();

        login.loginretrive(username, password);
      //  if (login.loginretrive(username, password) == null)
      //  {
           // TomShane.Neoforce.Controls.MessageBox.Show(Manager, TomShane.Neoforce.Controls.MessageBox.MessageBoxType.CANCEL, "ERRO USERNAME NAO EXISTE" , "");

      //      pw.Write((ushort)ErrorCodes.InvalidLogin);
      //  }
        if (login.loginretrive(username, password)=="YES")
        {
            //TomShane.Neoforce.Controls.MessageBox.Show(Manager, TomShane.Neoforce.Controls.MessageBox.MessageBoxType.CANCEL, "DEU", "");

            pw.Write((ushort)ErrorCodes.Sucess);
           // login.nivel(username);

          
        }
        else if (login.loginretrive(username, password).Equals("NO"))
        {

            pw.Write((ushort)ErrorCodes.Error);
                }
       // else {
        //    pw.Write((ushort)ErrorCodes.Error);
        pw.Write((ushort)Headers.Login);       // }
        SendPacktWriter(client, pw);
    }
        
        
          //  TomShane.Neoforce.Controls.MessageBox.Show(Manager, TomShane.Neoforce.Controls.MessageBox.MessageBoxType.CANCEL, "ERRO AO CONECTAR A BASE DE DADOS", "");
               

    ////////////////////////////////////////////////////////////////////////////

    #endregion

    #region //// Methods ///////////

    ////////////////////////////////////////////////////////////////////////////
    private void InitControls()
    {                  
      sidebar = new SideBar(Manager);            
      sidebar.Init();
      sidebar.StayOnBack = true;
      sidebar.Passive = true;            
      sidebar.Width = 200;
      sidebar.Height = ClientHeight;
      sidebar.Anchor = Anchors.Left | Anchors.Top | Anchors.Bottom;
  
      Add(sidebar);          
      InitRes();
      InitStats(); 
      InitSkins();
      Listener listener = new Listener();
      listener.Accepted += listener_Accepted;
      listener.start(PORT);
      //System.Diagnostics.Process.GetCurrentProcess().WaitForExit();
                           
    }
    ////////////////////////////////////////////////////////////////////////////   
        

    ////////////////////////////////////////////////////////////////////////////
    private void InitRes()
    {
      pnlRes = new SideBarPanel(Manager);
      pnlRes.Init();
      pnlRes.Passive = true;
      pnlRes.Parent = sidebar;      
      pnlRes.Left = 16;
      pnlRes.Top = 16;
      pnlRes.Width = sidebar.Width - pnlRes.Left;
      pnlRes.Height = 86;      
      pnlRes.CanFocus = false;                 

  
      btnApply = new Button(Manager);
      btnApply.Init();
      btnApply.Width = 80;
      btnApply.Parent = sidebar;
      btnApply.Left = pnlRes.Left;      
      btnApply.Top = pnlRes.Top + pnlRes.Height + 8;
      btnApply.Text = "Apply";
      btnApply.Click += new Controls.EventHandler(btnApply_Click);
     // System.Console.WriteLine("HEELO");
      btnExit = new Button(Manager);
      btnExit.Init();
      btnExit.Width = 80;
      btnExit.Parent = sidebar;
      btnExit.Left = btnApply.Left + btnApply.Width + 8;
      btnExit.Top = pnlRes.Top + pnlRes.Height + 8;
      btnExit.Text = "Exit";
      btnExit.Click += new Controls.EventHandler(btnExit_Click);            
    }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySql.Data.MySqlClient;
using System.Windows.Forms;
using System.Security.Cryptography;
using System.Security;
using System.Net.Sockets;
using System.IO;
namespace TomShane.Neoforce.Central.Code
{
    class Login
    {
       // private DBConnect dbConnect;
      //  public Socket c_scoket;
        public int id_user;
     //   public uint dwsessions;
        String username;
        String password;
        public int tipo;
      //  public bool bIsBusy;
        public byte[] remains = null;
       // public NetworkStream n_stream;
      //  BinaryWriter Writer { get; set; }
       // BinaryReader Reader { get; set; }
       
        public int Id
        {

            get { return id_user; }
            set { id_user = value; }
        }
        public String Username
        {
            get { return username; }
            set { username = value; }
        }
        public String Password
        {
            get { return password; }
            set { password = value; }
        }
        public int Tipo
        {
            get { return tipo; }
            set { tipo = value; }
        }
       /* private Login(Socket s)
        {
           //;
           this.c_scoket = s;
           this.id_user = 1;
           this.dwsessions=(uint)new Random().Next(0,ushort.MaxValue*5);
           this.bIsBusy = false;
            this.n_stream= new NetworkStream(s);
            this.Writer = new BinaryWriter(n_stream);
            this.Reader = new BinaryReader(n_stream);
            
       }
        */

       /* public void Handlepack() {
            Packet pak;
            while ((pak = Recieve()) != null)
            {
                switch (pak._PacketTypeLogin)
                {
                  
                }
            }
        }
        * */
      /*  Packet recive() { 
        
        
        }
       * */
        public int nivel(string username){
            try
            {
                MySqlConnection con = new MySqlConnection("host=localhost;user=root;database=gest");

                MySqlCommand cmdo = new MySqlCommand("SELECT tipo FROM user WHERE Username= '" + username + "'");
                cmdo.Connection = con;
                con.Open();
                object Tipo = cmdo.ExecuteScalar();
                if (Tipo != null && Tipo != DBNull.Value)
                {
                    tipo = System.Convert.ToInt32(Tipo);

                    con.Close();
                    return tipo; 
                    
                   
                } else{
                   
                    
                     con.Close();
                     return -1;
                }
                    

               




            }
            catch (MySqlException)
            {
                
                return 0;
              
            }
        }
        
                        
         public  string loginretrive(string username, string password) 
        {
               
            try
            {

               

                MySqlConnection con = new MySqlConnection("host=localhost;user=root;database=gest");

                MySqlCommand cmd = new MySqlCommand("SELECT password FROM user WHERE Username  ='" + username + "'");
                cmd.Connection = con;
                con.Open();
                object hello = cmd.ExecuteScalar();
                if (hello == null)
                {
                   
                    return null;
                }
                else
                {
                    string Password = hello.ToString();

                    String userPassword = password; // que hizo el usuario escribe?                
                   // con.Close();
                    if (Login.Equals(Password, password))
                    {
                        
                      
                        return "YES";
                       // return true;
                        // corregir!
                       /* MySqlCommand cmdo = new MySqlCommand("SELECT w70tg_user_usergroup_map.group_id FROM w70tg_users INNER JOIN w70tg_user_usergroup_map on w70tg_user_usergroup_map.user_id=w70tg_users.id  WHERE username  = '" + username + "'");
                        cmdo.Connection = con;
                        con.Open();
                        object Tipo = cmdo.ExecuteScalar();
                        if (Tipo != null && Tipo != DBNull.Value)
                        {
                           tipo=System.Convert.ToInt32(Tipo);
                          
                            switch (tipo)
                            {
                                case 8:
                                    //string tipo2 = System.Convert.ToString(tipo);
                                   // return tipo;
                                MessageBox.Show("ADMINISTRADOR");
                                    break;
                                case 11:
                                    MessageBox.Show("GAME MASTER");
                                    break;
                                case 10:
                                    MessageBox.Show("Moderador");
                                    break;
                                case 3:
                                    MessageBox.Show("VIP");
                                    break;
                                case 2:
                                    MessageBox.Show("Membro");
                                    break;
                                case 1:
                                    MessageBox.Show("O Utilizador foi banido\n Contacte a Equipa atravez do suporte para saber a razão pelo qual foi banido(a)");
                                    break;
                            }
                        
                        }
                        * */
                    }
                    else
                    {
                       
                        con.Close();
                        return "NO";

                    }
                   
                }
            }
            catch (MySqlException msqle)
            {
                
                return msqle.Message;
            }
        }
    }
}

how i solve the problem maybe the error is i commend the invoked part

someone can help-me 

Edited by Landi20

Share this post


Link to post
Share on other sites
hplus0603    11347

First, posting all your source will not help anyone.

 

Second, what is the problem? Are you getting a compile error? If so, you should copy-and-paste the error, and the few lines of code that generate that error.

 

Third, tracking down compile errors should be very easy for someone who actually knows how to program. If you don't know how to fix that, you are not prepared to develop distributed, asynchronous, systems, such as networked games. I suggest you learn to program and use your tools first, or your project will be an exercise in frustration.

 

Moving to a better forum for this particular question.

Share this post


Link to post
Share on other sites
Landi20    257

finaly i find the problem

the problem is not in the client but in the server

this is the solution

 static void Logger(Client client, string username, string password)
    {
        Login login = new Login();
        PacketWriter pw = new PacketWriter();

        login.loginretrive(username, password);
      pw.Write((ushort)Headers.Login); 
        if (login.loginretrive(username, password)=="YES")
        {
 
            pw.Write((ushort)ErrorCodes.Sucess);
          

          
        }
        else 
        {

            pw.Write((ushort)ErrorCodes.Error);
                }
      

        SendPacktWriter(client, pw);
    }
Edited by Landi20

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this