1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
| Imports MySql.Data.MySqlClient
Imports System.Net.Sockets
Imports System.Net
Imports System.Threading
Public Class Form1
Dim sermysqltest As String
Dim droit As String
Dim passeadmi As String
Dim database As String
Dim connectionglobal
Dim port As String = "203"
Dim ip As String = "127.0.0.1"
Public id As Object
Structure acceuilclient
Dim id_ac As Integer
Dim nom_ac As String
Dim passe_ac As String
Dim mel_ac As String
Dim date_ac As String
Dim heure_ac As String
End Structure
Dim joueurs
Dim joueur As String
Dim url_joueur As String
Dim pos_joueur As String
Dim rot_joueur As String
Dim action_avat_joueur As Integer
Public Sub SQL
sermysqltest = "127.0.0.1"
droit = "root"
passeadmi = ""
database = "mabase"
End Sub
Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Sub MonThread()
Dim MonSocketServeur As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim MonEP As IPEndPoint = New IPEndPoint(IPAddress.Parse(ip), port)
MonSocketServeur.Bind(MonEP) 'Lie le socket à cette IP
MonSocketServeur.Listen(1) 'Se met en mode écoute
Label3.Text = "CONNEXION EN ATTENTE"
Dim SocketEnvoi As Socket = MonSocketServeur.Accept() 'Bloquant tant que pas de connexion
imagechat.BackColor = Color.Green
Label3.Text = "CONNEXION REUSSIE"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Call SQL()
Dim serveurgeneral As String = "Database=" + database + ";Data Source=" + sermysqltest + ";User Id=" + droit + ";Password=" + passeadmi
Dim myConnection As New MySqlConnection(serveurgeneral)
Try
myConnection.Open()
Catch
Label2.Text = "Serveur non joignable"
imagesql.BackColor = Color.Red
Exit Sub
End Try
imagesql.BackColor = Color.Green
Label2.Text = "BASE MYSQL EN SERVICE"
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim serveurgeneral As String = "Database=" + database + ";Data Source=" + sermysqltest + ";User Id=" + droit + ";Password=" + passeadmi
Dim myConnection As New MySqlConnection(serveurgeneral)
myConnection.Close()
imagesql.BackColor = Color.Red
Label2.Text = "BASE MYSQL HORS SERVICE"
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If Label2.Text <> "BASE MYSQL EN SERVICE" Then
Label2.Text = "BASE MYSQL HORS SERVICE" + Chr(13) + "OPTIMIZATION IMPOSSIBLE"
Exit Sub
End If
imagesql.BackColor = Color.Orange
Dim v(10)
Dim serveurgeneral As String = "Database=" + database + ";Data Source=" + sermysqltest + ";User Id=" + droit + ";Password=" + passeadmi
Dim optimize As String = "OPTIMIZE TABLE joueur;"
Dim myConnection As New MySqlConnection(serveurgeneral)
Dim myCommand As New MySqlCommand(optimize)
Dim requete2 As String = "OPTIMIZE TABLE joueur;"
Dim cmd As MySqlCommand = New MySqlCommand(requete2, myConnection)
cmd.CommandText = optimize
Label2.Text = "OPTIMIZATION DE LA BASE MSQL"
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
imagesql.BackColor = Color.Green
Label2.Text = "BASE MYSQL EN SERVICE"
Timer1.Stop()
Exit Sub
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
'Crée le socket et l'IP EP
Dim MonSocketServeur As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim MonEP As IPEndPoint = New IPEndPoint(IPAddress.Any, port)
Try
MonSocketServeur.Bind(MonEP) 'Lie le socket à cette IP
MonSocketServeur.Listen(1) 'Se met en écoute
imagechat.BackColor = Color.SeaGreen
Catch ex As Exception
Label3.Text = ex.ToString
End Try
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim MonSocketServeur As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim MonEP As IPEndPoint = New IPEndPoint(IPAddress.Parse(ip), port)
MonSocketServeur.Close()
imagechat.BackColor = Color.Red
Label3.Text = "SERVEUR CHAT ETEINT"
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim serveurgeneral As String = "Database=" + database + ";Data Source=" + sermysqltest + ";User Id=" + droit + ";Password=" + passeadmi
Dim myConnection As New MySqlConnection(serveurgeneral)
Try
myConnection.Open()
Catch
Label2.Text = "Serveur non joignable"
imagesql.BackColor = Color.Red
Exit Sub
End Try
imagesql.BackColor = Color.Green
Label2.Text = "BASE MYSQL EN SERVICE"
Timer2.Start()
End Sub
Public Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
Dim serveurgeneral As String = "Database=" + database + ";Data Source=" + sermysqltest + ";User Id=" + droit + ";Password=" + passeadmi
Dim myConnection As New MySqlConnection(serveurgeneral)
myConnection.Close()
imagesql.BackColor = Color.Red
Label2.Text = "BASE MYSQL HORS SERVICE"
Dim MonSocketServeur As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim MonEP As IPEndPoint = New IPEndPoint(IPAddress.Parse(ip), port)
MonSocketServeur.Close()
imagechat.BackColor = Color.Red
Label3.Text = "SERVEUR CHAT ETEINT"
End Sub
Private Sub GroupBox4_Enter(sender As Object, e As EventArgs) Handles GroupBox4.Enter
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
cc3d.url = "http://www.starenda.info/3d/no_cache/debut.wrl"
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
cc3d.url = "/debut.wrl"
' deux boutons pour la meme choses, NA
' joueurs(id) = 0
End Sub
Public Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Dim serveurgeneral As String = "Database=" + database + ";Data Source=" + sermysqltest + ";User Id=" + droit + ";Password=" + passeadmi
Dim myConnection As New MySqlConnection(serveurgeneral)
Try
myConnection.Open()
Catch
Label2.Text = "Serveur non joignable"
imagesql.BackColor = Color.Red
Exit Sub
End Try
imagesql.BackColor = Color.GreenYellow
Label2.Text = "BASE MYSQL EN SERVICE"
End Sub
End Class |
Partager