Exemplo n.º 1
0
 public static void InitializeNetwork()
 {
     Yazi.Log_yaz("Paketleriniz Başlatılıyor");
     ServerHandleData.InitializePackets();
     serverSocket.Start();
     serverSocket.BeginAcceptTcpClient(new AsyncCallback(OnClientConnet), null);
 }
Exemplo n.º 2
0
        public MySqlConnection MySqlBaslat()
        {
            try
            {
                MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder();
                builder.UserID             = "root";
                builder.Password           = "";
                builder.Database           = "youtubeegitim";
                builder.Server             = "localhost";
                builder.Pooling            = true;
                builder.ConnectionLifeTime = 0;
                builder.ConnectionTimeout  = 30;

                string connString = builder.ToString();

                MySqlConnection baglanti = new MySqlConnection(connString);

                if (baglanti.State != ConnectionState.Open)
                {
                    baglanti.Open();
                    Yazi.Log_yaz("Mysql Connection Acildi");
                    return(baglanti);
                }

                return(null);
            }
            catch (Exception e)
            {
                Yazi.Hata_Yaz("MySql Bağlantısı Hatası : " + e.Message);
                return(null);
            }
        }
 public void baglanti_control(MySqlConnection baglanti)
 {
     if (baglanti.State != ConnectionState.Open)
     {
         baglanti.Open();
         Yazi.Log_yaz(connectionID.ToString() + " Kullanıcısının Bağlantısı Tekrar Açıldı");
     }
 }
Exemplo n.º 4
0
        public int MySqlVeri_Sil(MySqlConnection baglanti, String SqlCommand, String Select = null, ArrayList WhereList = null)
        {
            String sol, sag;

            try
            {
                if (SqlCommand == null)
                {
                    SqlCommand = Select;

                    SqlCommand = SqlCommand + " WHERE ";

                    for (int i = 0; i < WhereList.Count; i++)
                    {
                        sol = WhereList[i].ToString().Split('=')[0];
                        sag = WhereList[i].ToString().Split('=')[1];

                        if (WhereList.Count == 1)
                        {
                            SqlCommand = SqlCommand + sol + "=" + "'" + sag + "'";
                        }
                        else if (i < WhereList.Count - 1)
                        {
                            SqlCommand = SqlCommand + sol + "=" + "'" + sag + "'" + " AND ";
                        }
                        else if (i == WhereList.Count - 1)
                        {
                            SqlCommand = SqlCommand + sol + "=" + "'" + sag + "'" + "";
                        }
                    }
                }
                else
                {
                }

                Console.WriteLine(SqlCommand);

                MySqlCommand guncelle = null;
                guncelle = new MySqlCommand(SqlCommand, baglanti);

                if (guncelle != null)
                {
                    int id = Convert.ToInt32(guncelle.ExecuteNonQuery());
                    return(id);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception e)
            {
                Yazi.Hata_Yaz("MySql Hatası : " + e.Message);
                baglanti.Close();
                throw;
            }
        }
Exemplo n.º 5
0
        public MySqlCommand MySql_Veri_Cek(MySqlConnection baglanti, String SqlCommand = null, String Select = null, ArrayList WhereList = null)
        {
            try
            {
                ArrayList tablo_Adi    = new ArrayList();
                ArrayList eklenen_veri = new ArrayList();

                if (SqlCommand == null)
                {
                    SqlCommand = Select;

                    if (WhereList != null)
                    {
                        SqlCommand = SqlCommand + " WHERE (";

                        for (int i = 0; i < WhereList.Count; i++)
                        {
                            if (WhereList.Count == 1)
                            {
                                SqlCommand = SqlCommand + WhereList[i].ToString() + ");";
                            }
                            else if (i < WhereList.Count - 1)
                            {
                                SqlCommand = SqlCommand + WhereList[i].ToString() + " AND ";
                            }
                            else if (i == WhereList.Count - 1)
                            {
                                SqlCommand = SqlCommand + WhereList[i].ToString() + ");";
                            }
                        }
                    }
                }

                Console.WriteLine(SqlCommand);
                MySqlCommand cmd   = new MySqlCommand(SqlCommand, baglanti);
                int          Count = Convert.ToInt32(cmd.ExecuteScalar());

                Console.WriteLine("Karakter Sayısı : " + Count);

                if (Count != 0)
                {
                    return(cmd);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                Yazi.Hata_Yaz("MySql Hatası : " + e.Message);
                baglanti.Close();
                throw;
            }
        }
Exemplo n.º 6
0
        public static void HandleMerhabaServer(int connectionID, byte[] data)
        {
            Kaan_ByteBuffer buffer = new Kaan_ByteBuffer();

            buffer.Bytes_Yaz(data);
            int    packetID = buffer.Int_Oku();
            string msg      = buffer.String_Oku();

            buffer.Dispose();
            Yazi.Gelen_Mesaj(connectionID + " " + msg);
            DataSender.SendHodsgeldinMesaji(connectionID);
        }
Exemplo n.º 7
0
        public static void StartGameServer()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            ServerTCP.InitializeNetwork();
            Yazi.Log_yaz("Sunucu Başlatıldı...");
            sw.Stop();

            Yazi.Log_yaz(text: $"Sunucu Başlama Süresi {sw.ElapsedMilliseconds} ms");
        }
Exemplo n.º 8
0
        public static void Sunucuyu_Baslat()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            ServerTCP.InitializeNetwork();
            Yazi.Log_yaz("Sunucu Başlatıldı");

            Sabitler.Sunucu_MySql_Baglanti = Sabitler.Mysql_Data.MySqlBaslat();
            Yazi.Log_yaz("MySQL Sunucu Başlatıldı");

            sw.Stop();
            Yazi.Log_yaz("Sunucu Başlama Süresi : " + sw.ElapsedMilliseconds.ToString() + "ms");
        }
Exemplo n.º 9
0
        public static void HandleLoginGiris(int connectionID, byte[] data)
        {
            Kaan_ByteBuffer buffer = new Kaan_ByteBuffer();

            buffer.Bytes_Yaz(data);
            int    packetID      = buffer.Int_Oku();
            string kullanici_adi = buffer.String_Oku();
            string sifre         = buffer.String_Oku();

            ArrayList Ara = new ArrayList();

            Ara.Add("kullanici_adi='" + kullanici_adi + "'");
            Ara.Add("sifre='" + sifre + "'");

            MySqlCommand cmd = Sabitler.Mysql_Data.MySql_Veri_Cek(Sabitler.bagli_client[connectionID].baglanti, null, "Select * From tum_kullanicilar", Ara);

            if (cmd != null)
            {
                MySqlDataReader oku = cmd.ExecuteReader();

                int id = 0;
                while (oku.Read())
                {
                    //////
                    id = (int)oku["id"];
                    Yazi.Log_yaz("Bağlanan Kullanıcın Kullancı ID si : " + id.ToString());
                }
                oku.Close();

                ///
                DataSender.SendLoginGirisCevap(connectionID, 1);
            }
            else
            {
                DataSender.SendLoginGirisCevap(connectionID, 0);
            }
            buffer.Dispose();
        }
Exemplo n.º 10
0
 public static void Oyuncu_Cikti(string connectionId)
 {
     BagliKullaniciSayisi--;
     Yazi.Log_yaz("Kullanıcı Ayrıldı : " + connectionId);
     Sabitler.server.listBox1.Items.Remove(connectionId);
 }
Exemplo n.º 11
0
 public static void Oyuncu_Baglandi(string connectionId)
 {
     BagliKullaniciSayisi++;
     Yazi.Log_yaz("Kullanıcı Bağlandı : " + connectionId);
     Sabitler.server.listBox1.Items.Add(connectionId);
 }
Exemplo n.º 12
0
 public static void oyuncu_cikti(string connectionID)
 {
     bagli_kullanici_sayisi--;
     Yazi.Log_yaz("Kullanıcı Sunucudan Ayrıldı : " + connectionID);
     Sabitler.server.listBox1.Items.Remove(connectionID);
 }
Exemplo n.º 13
0
 public static void oyuncu_baglandi(string connectionID)
 {
     bagli_kullanici_sayisi++;
     Yazi.Log_yaz("Kullanıcı Servere Bağlandı : " + connectionID);
     Sabitler.server.listBox1.Items.Add(connectionID);
 }
Exemplo n.º 14
0
        public int MySql_Veri_Kaydet(MySqlConnection baglanti, String tablo_adi, ArrayList Eklenecek_Veri)
        {
            string SqlCommand = "Insert Into " + tablo_adi + " (";

            try
            {
                ArrayList tablo_Adi    = new ArrayList();
                ArrayList eklenen_veri = new ArrayList();

                for (int i = 0; i < Eklenecek_Veri.Count; i++)
                {
                    tablo_Adi.Add(Eklenecek_Veri[i].ToString().Split(',')[0]);
                    eklenen_veri.Add(Eklenecek_Veri[i].ToString().Split(',')[1]);
                }

                for (int i = 0; i < Eklenecek_Veri.Count; i++)
                {
                    if (i < Eklenecek_Veri.Count - 1)
                    {
                        SqlCommand = SqlCommand + tablo_Adi[i].ToString() + ", ";
                    }
                    else if (i == Eklenecek_Veri.Count - 1)
                    {
                        SqlCommand = SqlCommand + tablo_Adi[i].ToString() + ") VALUES ('";
                    }
                }

                for (int i = 0; i < Eklenecek_Veri.Count; i++)
                {
                    if (Eklenecek_Veri.Count == 1)
                    {
                        SqlCommand = SqlCommand + eklenen_veri[i].ToString() + "'); " +
                                     "SELECT LAST_INSERT_ID();";
                    }
                    else if (i < Eklenecek_Veri.Count - 1)
                    {
                        SqlCommand = SqlCommand + eklenen_veri[i].ToString() + "', '";
                    }
                    else if (i == Eklenecek_Veri.Count - 1)
                    {
                        SqlCommand = SqlCommand + eklenen_veri[i].ToString() + "'); " +
                                     "SELECT LAST_INSERT_ID();";
                    }
                }

                MySqlCommand ekle = null;
                ekle = new MySqlCommand(SqlCommand, baglanti);

                if (ekle != null)
                {
                    int id = Convert.ToInt32(ekle.ExecuteScalar());
                    return(id);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception e)
            {
                Yazi.Hata_Yaz("MySql Hatası : " + e.Message);
                baglanti.Close();
                throw;
            }
        }