Merge pull request #58 from progtime-net/ForwardingDataServer

Forwarding data server
This commit is contained in:
SergoDobro 2024-08-18 13:51:29 +03:00 committed by GitHub
commit 022cc97afd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 9 additions and 7 deletions

View file

@ -85,9 +85,6 @@
/processorParam:Quality=Best
/build:sounds/Zombi stoit.wav
#begin Textures/Animations/player_idle_rotate_weapon.animation
/copy:Textures/Animations/player_idle_rotate_weapon.animation
#begin Textures/Animations/player_idle_top_noweapon.animation
/copy:Textures/Animations/player_idle_top_noweapon.animation

View file

@ -51,6 +51,7 @@ namespace ZoFo.GameCore
{
List<UpdateData> updateDatas = JsonSerializer.Deserialize<List<UpdateData>>(data);
// тут будет switch
AppManager.Instance.debugHud.Log(data);
foreach (var item in updateDatas)
{
GotData(item);
@ -78,6 +79,7 @@ namespace ZoFo.GameCore
{
for (int i = 0; i < gameObjects.Count; i++)
{
AppManager.Instance.debugHud.Set("GameTime", gameTime.TotalGameTime.ToString());
gameObjects[i].UpdateAnimations();
}
}

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography.X509Certificates;
@ -87,7 +88,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
/// </summary>
public void JoinYourself(int port) // single player
{
endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port);
endPoint = new IPEndPoint(GetIp(), port);
socket.Connect(endPoint);
SendData();
Thread listen = new Thread(StartListening);
@ -97,8 +98,9 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
public static IPAddress GetIp()
{
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
string myIP = Dns.GetHostByName(hostName).AddressList[1].ToString();// Get the IP
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
var ipList = Dns.GetHostByName(hostName).AddressList;
string myIP = ipList[ipList.Count() - 1].ToString();// Get the IP
return IPAddress.Parse(myIP);
}

View file

@ -37,7 +37,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
/// </summary>
private void Init()
{
endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port);
endPoint = new IPEndPoint(GetIp(), port);
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
managerThread = new Dictionary<Socket, Thread>();
clients = new List<Socket>();

View file

@ -43,6 +43,7 @@ namespace ZoFo.GameCore
public void OnDataSend(string data)
{
List<UpdateData> updateDatas = JsonSerializer.Deserialize<List<UpdateData>>(data);
AppManager.Instance.debugHud.Log(data);
for (int i = 0; i < updateDatas.Count; i++)
{
ProcessIUpdateData(updateDatas[i]);