Further parse bunches till their channel receives them
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using Prospect.Unreal.Core;
|
||||
using Prospect.Unreal.Net;
|
||||
using Prospect.Unreal.Net.Channels;
|
||||
using Prospect.Unreal.Net.Packets.Bunch;
|
||||
using Serilog;
|
||||
|
||||
namespace Prospect.Unreal.Runtime;
|
||||
|
||||
public abstract class UWorld : IAsyncDisposable
|
||||
public abstract class UWorld : FNetworkNotify, IAsyncDisposable
|
||||
{
|
||||
private static readonly ILogger Logger = Log.ForContext<UWorld>();
|
||||
|
||||
@@ -36,7 +38,7 @@ public abstract class UWorld : IAsyncDisposable
|
||||
NetDriver = new UIpNetDriver(Url.Host, Url.Port);
|
||||
NetDriver.SetWorld(this);
|
||||
|
||||
if (!NetDriver.Init())
|
||||
if (!NetDriver.Init(this))
|
||||
{
|
||||
Logger.Error("Failed to listen");
|
||||
NetDriver = null;
|
||||
@@ -46,6 +48,44 @@ public abstract class UWorld : IAsyncDisposable
|
||||
return true;
|
||||
}
|
||||
|
||||
public EAcceptConnection NotifyAcceptingConnection()
|
||||
{
|
||||
return EAcceptConnection.Accept;
|
||||
}
|
||||
|
||||
public void NotifyAcceptedConnection(UNetConnection connection)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool NotifyAcceptingChannel(UChannel channel)
|
||||
{
|
||||
var driver = channel.Connection.Driver!;
|
||||
if (!driver.IsServer())
|
||||
{
|
||||
throw new NotSupportedException("Client code");
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are the server.
|
||||
if (driver.ChannelDefinitionMap[channel.ChName].ClientOpen)
|
||||
{
|
||||
// The client has opened initial channel.
|
||||
Logger.Verbose("NotifyAcceptingChannel {ChName} {ChIndex} server {FullName}: Accepted", channel.ChName, channel.ChIndex, typeof(UWorld).FullName);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Client can't open any other kinds of channels.
|
||||
Logger.Verbose("NotifyAcceptingChannel {ChName} {ChIndex} server {FullName}: Refused", channel.ChName, channel.ChIndex, typeof(UWorld).FullName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void NotifyControlMessage(UNetConnection connection, byte messageType, FInBunch bunch)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
if (NetDriver != null)
|
||||
|
||||
Reference in New Issue
Block a user