public static void Oyuncu_cikti(string connectionID) { bagli_kullanici_sayisi--; Yazi.Log_Yaz("Kullanıcı Serverdan ayrıldı : " + connectionID); Sabitler.server.listBox1.Items.Remove(connectionID); }
public MySqlConnection MySqlBaslat() { try { MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder(); builder.UserID = "root"; builder.Password = ""; builder.Database = "login"; 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 static void Oyuncu_baglandi(string connectionID) { bagli_kullanici_sayisi++; Yazi.Log_Yaz("Kullanıcı Servera Bağlandı : " + connectionID); Sabitler.server.listBox1.Items.Add(connectionID); ServerHandleData.InitializePackets(); }
public static void InitializeNetwork() { Yazi.Log_Yaz("Paketleriniz Baslatılıyor"); serverSocket.Start(); serverSocket.BeginAcceptTcpClient(new AsyncCallback(OnClientConnet), null); }
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; } }
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; } }
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(); Yazi.Gelen_Mesaj(connectionID + " " + msg); buffer.Dispose(); }
public static void Sunucuyu_Baslat() { Stopwatch sw = new Stopwatch(); sw.Start(); ServerTCP.InitializeNetwork(); Yazi.Log_Yaz("Sunucu Başlatıldı"); sw.Stop(); Yazi.Log_Yaz("Sunucu Başlama Süresi " + sw.ElapsedMilliseconds.ToString() + "ms"); }
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; } }