TCP for world transfer

wichtige daten bei der UDP übertragung gehen verloren.
This commit is contained in:
brausjonas
2022-05-13 02:48:53 +02:00
parent afedf345f8
commit 8b2ac28a16
11 changed files with 102 additions and 76 deletions
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 50 KiB

@@ -50,7 +50,7 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
+25 -9
View File
@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
@@ -26,9 +27,8 @@ public class Client
//setup client
client = new UdpClient();
client.DontFragment = false;
IPAddress address;
if (IPAddress.TryParse(hostname, out address))
if (IPAddress.TryParse(hostname, out IPAddress address))
{
address = IPAddress.Parse(hostname);
client.Connect(address, port);
@@ -50,7 +50,7 @@ public class Client
}
Send(sendList.ToArray());
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 0);
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 8051);
byte[] data = client.Receive(ref endPoint);
if (data[0] == 2)
{
@@ -64,10 +64,23 @@ public class Client
byte xChunk = 0;
byte zChunk = 0;
TcpClient tcpClient = new TcpClient();
if (address != null)
{
address = IPAddress.Parse(hostname);
tcpClient.Connect(address, port);
}
else
{
tcpClient.Connect(hostname, port);
}
StreamReader reader = new StreamReader(tcpClient.GetStream());
while (true)
{
endPoint = new IPEndPoint(IPAddress.Any, 0);
data = client.Receive(ref endPoint);
data = Encoding.ASCII.GetBytes(reader.ReadLine());
if (data[0] == 1)
{
@@ -102,23 +115,26 @@ public class Client
zChunk = 0;
}
}
Send(new byte[]{5});
}
reader.Close();
tcpClient.Close();
world.CreateChunks();
//world transfer finished
//start listening
receiveThread = new Thread(Receive);
receiveThread.Start();
Send(new byte[]{6});
}
private void Receive()
{
while(true)
{
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 0);
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 8051);
byte[] data = client.Receive(ref endPoint);
if (data[0] == 3)
@@ -42,8 +42,8 @@ PlayerSettings:
m_SplashScreenLogos: []
m_VirtualRealitySplashScreen: {fileID: 0}
m_HolographicTrackingLossScreen: {fileID: 0}
defaultScreenWidth: 1024
defaultScreenHeight: 768
defaultScreenWidth: 512
defaultScreenHeight: 384
defaultScreenWidthWeb: 960
defaultScreenHeightWeb: 600
m_StereoRenderingPath: 0
@@ -88,7 +88,7 @@ PlayerSettings:
bakeCollisionMeshes: 0
forceSingleInstance: 0
useFlipModelSwapchain: 1
resizableWindow: 0
resizableWindow: 1
useMacAppStoreValidation: 0
macAppStoreCategory: public.app-category.games
gpuSkinning: 1
@@ -99,7 +99,7 @@ PlayerSettings:
xboxEnableFitness: 0
visibleInBackground: 1
allowFullscreenSwitch: 1
fullscreenMode: 1
fullscreenMode: 3
xboxSpeechDB: 0
xboxEnableHeadOrientation: 0
xboxEnableGuest: 0
@@ -134,7 +134,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 0.1
bundleVersion: 0.2
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0