Implement handshake Hello NetControlMessage, recv and send
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using Prospect.Unreal.Core;
|
||||
using Prospect.Unreal.Exceptions;
|
||||
using Prospect.Unreal.Net;
|
||||
using Prospect.Unreal.Net.Channels;
|
||||
using Prospect.Unreal.Net.Packets.Bunch;
|
||||
using Prospect.Unreal.Net.Packets.Control;
|
||||
using Serilog;
|
||||
|
||||
namespace Prospect.Unreal.Runtime;
|
||||
@@ -60,7 +62,12 @@ public abstract class UWorld : FNetworkNotify, IAsyncDisposable
|
||||
|
||||
public bool NotifyAcceptingChannel(UChannel channel)
|
||||
{
|
||||
var driver = channel.Connection.Driver!;
|
||||
if (channel.Connection?.Driver == null)
|
||||
{
|
||||
throw new UnrealNetException();
|
||||
}
|
||||
|
||||
var driver = channel.Connection.Driver;
|
||||
if (!driver.IsServer())
|
||||
{
|
||||
throw new NotSupportedException("Client code");
|
||||
@@ -81,9 +88,59 @@ public abstract class UWorld : FNetworkNotify, IAsyncDisposable
|
||||
}
|
||||
}
|
||||
|
||||
public void NotifyControlMessage(UNetConnection connection, byte messageType, FInBunch bunch)
|
||||
public void NotifyControlMessage(UNetConnection connection, NMT messageType, FInBunch bunch)
|
||||
{
|
||||
if (NetDriver == null)
|
||||
{
|
||||
throw new UnrealNetException();
|
||||
}
|
||||
|
||||
if (!NetDriver.IsServer())
|
||||
{
|
||||
throw new NotSupportedException("Client code");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Verbose("Level server received: {MessageType}", messageType);
|
||||
|
||||
if (!connection.IsClientMsgTypeValid(messageType))
|
||||
{
|
||||
Logger.Error("IsClientMsgTypeValid FAILED ({MessageType}): Remote Address = {Address}", (int)messageType, connection.LowLevelGetRemoteAddress());
|
||||
bunch.SetError();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (messageType)
|
||||
{
|
||||
case NMT.Hello:
|
||||
{
|
||||
if (NMT_Hello.Receive(bunch, out var isLittleEndian, out var remoteNetworkVersion, out var encryptionToken))
|
||||
{
|
||||
// TODO: Version check.
|
||||
|
||||
if (string.IsNullOrEmpty(encryptionToken))
|
||||
{
|
||||
connection.SendChallengeControlMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException("Encryption");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case NMT.Login:
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
throw new NotImplementedException($"Unhandled control message {messageType}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
|
||||
Reference in New Issue
Block a user