public static void AddRoomToDatabase(LobbyRoom room, int port) { MySqlConnection mySqlConnection = new MySqlConnection("datasource=localhost;port=3306;username=root;password="******"INSERT INTO match_server.match_servers(isActive,UUID,IP,Port,PlayerUUIDs) VALUES('{0}','{room.UUID}','{""}','{port}','{room.GetPlayerUUIDs()}')", mySqlConnection); try { if (command.ExecuteNonQuery() == 1) { Console.WriteLine("Data Inserted"); } else { Console.WriteLine("Data Not Inserted"); } } catch (Exception exception) { Console.WriteLine(exception); } mySqlConnection.Close(); }
public static void CloseRoom(LobbyRoom room) { if (rooms.Contains(room)) { rooms.Remove(room); } }
public static void RoomStarted(int toClient, LobbyRoom room, string ip, int port, string token) { using (Packet packet = new Packet((int)ServerPackets.RoomStarted)) { packet.Write(room.UUID); packet.Write(ip); packet.Write(port); packet.Write(token); SendTCPData(toClient, packet); } }
public static void LobbyRoom(int toClient, LobbyRoom room) { using (Packet packet = new Packet((int)ServerPackets.LobbyRoom)) { packet.Write(room.UUID); packet.Write(room.RoomName); packet.Write(room.PlayerCount); packet.Write(room.GameTypeIndex); SendTCPData(toClient, packet); } }
public static void RoomData(int toClient, LobbyRoom room) { using (Packet packet = new Packet((int)ServerPackets.RoomData)) { packet.Write(room.RoomName); packet.Write(room.PlayerCount); for (int i = 0; i < room.PlayerCount; i++) { packet.Write(room.Players[i].playerName); packet.Write(room.Players[i].isReady); } SendTCPData(toClient, packet); } }
public static void CreateRoom(int fromClient, Packet packet) { if (!Server.clients[fromClient].isTokenChecked) { Server.clients[fromClient].tcp.Disconnect(); return; } string UUID = packet.ReadString(); if (string.Equals(Server.clients[fromClient].UUID, UUID)) { string roomName = packet.ReadString(); if (roomName.Length > 1) { roomName = roomName.Remove(roomName.Length - 1); LobbyRoomsManager.CreateRoom(fromClient, roomName); LobbyRoom room = LobbyRoomsManager.GetRoom(Server.clients[fromClient].UUID); if (room != null) { ServerSend.RoomData(fromClient, room); } } } }