GETIPFIX
This commit is contained in:
parent
2c3405d007
commit
4dd13f2a32
3 changed files with 14 additions and 4 deletions
|
@ -99,6 +99,10 @@ namespace ZoFo.GameCore
|
||||||
gameObjects[i].UpdateAnimations();
|
gameObjects[i].UpdateAnimations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void SendData()
|
||||||
|
{
|
||||||
|
networkManager.SendData();
|
||||||
|
}
|
||||||
internal void Draw(SpriteBatch spriteBatch)
|
internal void Draw(SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mapObjects.Count; i++)
|
for (int i = 0; i < mapObjects.Count; i++)
|
||||||
|
|
|
@ -34,8 +34,8 @@ public class WaitingForPlayersGUI : AbstractGUI
|
||||||
// string pcIp =
|
// string pcIp =
|
||||||
|
|
||||||
// string pcIp =
|
// string pcIp =
|
||||||
ip = new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 7, (int)(width / 4), (int)(height / 20)), text = AppManager.Instance.server.MyIp.ToString(), fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts/Font3" };
|
//ip = new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 7, (int)(width / 4), (int)(height / 20)), text = AppManager.Instance.server.MyIp.ToString(), fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts/Font3" };
|
||||||
Elements.Add(ip);
|
//Elements.Add(ip);
|
||||||
if (isHost)
|
if (isHost)
|
||||||
{
|
{
|
||||||
ip = new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 7, (int)(width / 4), (int)(height / 20)), text = AppManager.Instance.server.MyIp.ToString(), fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts\\Font3" };
|
ip = new Label(Manager) { rectangle = new Rectangle(width / 2 - (int)(width / 8), height / 7, (int)(width / 4), (int)(height / 20)), text = AppManager.Instance.server.MyIp.ToString(), fontColor = Color.White, mainColor = Color.Transparent, scale = 0.9f, fontName = "Fonts\\Font3" };
|
||||||
|
@ -72,6 +72,7 @@ public class WaitingForPlayersGUI : AbstractGUI
|
||||||
waitButton.LeftButtonPressed += () =>
|
waitButton.LeftButtonPressed += () =>
|
||||||
{
|
{
|
||||||
// start
|
// start
|
||||||
|
AppManager.Instance.client.SendData();
|
||||||
AppManager.Instance.ChangeState(GameState.ClientPlaying);
|
AppManager.Instance.ChangeState(GameState.ClientPlaying);
|
||||||
// ваш код здесь
|
// ваш код здесь
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||||
endPoint = new IPEndPoint(GetIp(), 8081);
|
endPoint = new IPEndPoint(GetIp(), 8081);
|
||||||
socket.Bind(endPoint);
|
socket.Bind(endPoint);
|
||||||
Thread thread = new Thread(StartListening);
|
Thread thread = new Thread(StartListening);
|
||||||
|
thread.IsBackground = true;
|
||||||
thread.Start();
|
thread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,14 +145,18 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
||||||
{
|
{
|
||||||
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
|
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
|
||||||
var ipList = Dns.GetHostEntry(hostName).AddressList;
|
var ipList = Dns.GetHostEntry(hostName).AddressList;
|
||||||
|
var ipV4List = new List<IPAddress>();
|
||||||
foreach (var ip in ipList)
|
foreach (var ip in ipList)
|
||||||
{
|
{
|
||||||
if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
|
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;
|
return IPAddress.Loopback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue