Added UWorld
This commit is contained in:
@@ -6,17 +6,17 @@ namespace Prospect.Unreal.Net;
|
||||
|
||||
public class UIpConnection : UNetConnection
|
||||
{
|
||||
public override void InitBase(UNetDriver inDriver, UdpClient inSocket, FURL inURL, EConnectionState inState, int inMaxPacket = 0, int inPacketOverhead = 0)
|
||||
public override void InitBase(UNetDriver inDriver, UdpClient inSocket, FUrl inURL, EConnectionState inState, int inMaxPacket = 0, int inPacketOverhead = 0)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void InitRemoteConnection(UNetDriver inDriver, UdpClient inSocket, FURL inURL, IPEndPoint inRemoteAddr, EConnectionState inState, int inMaxPacket = 0, int inPacketOverhead = 0)
|
||||
public override void InitRemoteConnection(UNetDriver inDriver, UdpClient inSocket, FUrl inURL, IPEndPoint inRemoteAddr, EConnectionState inState, int inMaxPacket = 0, int inPacketOverhead = 0)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void InitLocalConnection(UNetDriver inDriver, UdpClient inSocket, FURL inURL, EConnectionState inState,
|
||||
public override void InitLocalConnection(UNetDriver inDriver, UdpClient inSocket, FUrl inURL, EConnectionState inState,
|
||||
int inMaxPacket = 0, int inPacketOverhead = 0)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -11,9 +11,9 @@ public class UIpNetDriver : UNetDriver
|
||||
|
||||
private bool _isDisposed;
|
||||
|
||||
public UIpNetDriver()
|
||||
public UIpNetDriver(IPAddress host, int port)
|
||||
{
|
||||
ServerIp = new IPEndPoint(IPAddress.Any, 7777);
|
||||
ServerIp = new IPEndPoint(host, port);
|
||||
Socket = new UdpClient(ServerIp);
|
||||
ReceiveThread = new FReceiveThreadRunnable(this);
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public class UIpNetDriver : UNetDriver
|
||||
public UdpClient Socket { get; }
|
||||
public FReceiveThreadRunnable ReceiveThread { get; }
|
||||
|
||||
public bool Init()
|
||||
public override bool Init()
|
||||
{
|
||||
// Initialize connectionless packet handler.
|
||||
InitConnectionlessHandler();
|
||||
@@ -119,8 +119,7 @@ public class UIpNetDriver : UNetDriver
|
||||
returnVal.InitSequence(clientSequence, serverSequence);
|
||||
}
|
||||
|
||||
// TODO: World url
|
||||
returnVal.InitRemoteConnection(this, Socket, null, address, EConnectionState.USOCK_Open);
|
||||
returnVal.InitRemoteConnection(this, Socket, World != null ? World.Url : new FUrl(), address, EConnectionState.USOCK_Open);
|
||||
|
||||
// if (returnVal.Handler)
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ public abstract class UNetConnection
|
||||
public const int ReliableBuffer = 256;
|
||||
public const int MaxPacketId = 16384;
|
||||
|
||||
public abstract void InitBase(UNetDriver inDriver, UdpClient inSocket, FURL inURL, EConnectionState inState, int inMaxPacket = 0, int inPacketOverhead = 0);
|
||||
public abstract void InitRemoteConnection(UNetDriver inDriver, UdpClient inSocket, FURL inURL, IPEndPoint inRemoteAddr, EConnectionState inState, int inMaxPacket = 0, int inPacketOverhead = 0);
|
||||
public abstract void InitLocalConnection(UNetDriver inDriver, UdpClient inSocket, FURL inURL, EConnectionState inState, int inMaxPacket = 0, int inPacketOverhead = 0);
|
||||
public abstract void InitBase(UNetDriver inDriver, UdpClient inSocket, FUrl inURL, EConnectionState inState, int inMaxPacket = 0, int inPacketOverhead = 0);
|
||||
public abstract void InitRemoteConnection(UNetDriver inDriver, UdpClient inSocket, FUrl inURL, IPEndPoint inRemoteAddr, EConnectionState inState, int inMaxPacket = 0, int inPacketOverhead = 0);
|
||||
public abstract void InitLocalConnection(UNetDriver inDriver, UdpClient inSocket, FUrl inURL, EConnectionState inState, int inMaxPacket = 0, int inPacketOverhead = 0);
|
||||
public abstract void LowLevelSend(byte[] data, int countBits, FOutPacketTraits traits);
|
||||
public abstract string LowLevelGetRemoteAddress(bool bAppendPort = false);
|
||||
public abstract string LowLevelDescribe();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Net;
|
||||
using Prospect.Unreal.Runtime;
|
||||
|
||||
namespace Prospect.Unreal.Net;
|
||||
|
||||
@@ -12,6 +13,11 @@ public abstract class UNetDriver : IAsyncDisposable
|
||||
MappedClientConnections = new ConcurrentDictionary<IPEndPoint, UNetConnection>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// World this net driver is associated with
|
||||
/// </summary>
|
||||
public UWorld? World { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Map of <see cref="IPEndPoint"/> to <see cref="UNetConnection"/>.
|
||||
/// </summary>
|
||||
@@ -37,6 +43,11 @@ public abstract class UNetDriver : IAsyncDisposable
|
||||
|
||||
ConnectionlessHandler.InitializeComponents();
|
||||
}
|
||||
|
||||
public virtual bool Init()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual void TickDispatch(float deltaTime)
|
||||
{
|
||||
@@ -49,7 +60,22 @@ public abstract class UNetDriver : IAsyncDisposable
|
||||
}
|
||||
|
||||
public abstract bool IsNetResourceValid();
|
||||
|
||||
public void SetWorld(UWorld? inWorld)
|
||||
{
|
||||
if (World != null)
|
||||
{
|
||||
World = null;
|
||||
}
|
||||
|
||||
if (inWorld != null)
|
||||
{
|
||||
World = inWorld;
|
||||
|
||||
// TODO: AddInitialObjects?
|
||||
}
|
||||
}
|
||||
|
||||
public double GetElapsedTime()
|
||||
{
|
||||
return _elapsedTime;
|
||||
|
||||
Reference in New Issue
Block a user