RDPUpdate2

This commit is contained in:
rawer470 2024-08-19 13:12:49 +03:00
commit b1cc401b08
3 changed files with 12 additions and 2 deletions

View file

@ -99,6 +99,10 @@ namespace ZoFo.GameCore
gameObjects[i].UpdateAnimations();
}
}
public void SendData()
{
networkManager.SendData();
}
internal void Draw(SpriteBatch spriteBatch)
{
for (int i = 0; i < mapObjects.Count; i++)

View file

@ -72,6 +72,7 @@ public class WaitingForPlayersGUI : AbstractGUI
waitButton.LeftButtonPressed += () =>
{
// start
AppManager.Instance.client.SendData();
AppManager.Instance.ChangeState(GameState.ClientPlaying);
// ваш код здесь
};

View file

@ -38,6 +38,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
endPoint = new IPEndPoint(GetIp(), 8081);
socket.Bind(endPoint);
Thread thread = new Thread(StartListening);
thread.IsBackground = true;
thread.Start();
}
@ -144,14 +145,18 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
{
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
var ipList = Dns.GetHostEntry(hostName).AddressList;
var ipV4List = new List<IPAddress>();
foreach (var ip in ipList)
{
if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
return ip;
ipV4List.Add(ip);
}
}
if (ipV4List.Count>0)
{
return ipV4List[ipV4List.Count - 1];
}
return IPAddress.Loopback;
}