Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix flatbuffers not handled correctly #277

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@

public bool RunAsyncTasks { get; set; } = true;

float screenScale = 1.0f;

Check warning on line 121 in Source/Coop/Components/CoopGameComponents/SITGameComponent.cs

View workflow job for this annotation

GitHub Actions / Build-SIT (Debug)

The field 'SITGameComponent.screenScale' is assigned but its value is never used

Camera GameCamera { get; set; }

Expand Down Expand Up @@ -321,15 +321,13 @@

builder.Finish(packetOffset.Value);

// NOTE(belette) Abstraction zealots in shambles, we never needed inheritance, we had if and switch all along, we can see what's happening inline IDONTWANNAHEARIT
if (Singleton<ISITGame>.Instance.GameClient is GameClientUDP udp)
{
var seg = builder.DataBuffer.ToArraySegment(builder.DataBuffer.Position, builder.DataBuffer.Length - builder.DataBuffer.Position);
udp.SendData(seg.Array, seg.Offset, seg.Count, SITGameServerClientDataProcessing.FLATBUFFER_CHANNEL_NUM, LiteNetLib.DeliveryMethod.Sequenced);
}
else if (Singleton<ISITGame>.Instance.GameClient is GameClientTCPRelay relay)
else if (Singleton<ISITGame>.Instance.GameClient is GameClientTCPRelay)
{
// TODO(belette) fix TCP Relay recipient side to detect FlatBuffers and process as such
GameClient.SendData(builder.SizedByteArray());
}
}
Expand Down
14 changes: 9 additions & 5 deletions Source/Networking/GameClientUDP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,15 @@ public void ResetStats()

void INetEventListener.OnNetworkReceive(NetPeer peer, NetPacketReader reader, byte channelNumber, DeliveryMethod deliveryMethod)
{
var bytes = reader.GetRemainingBytes();
Singleton<SITGameServerClientDataProcessing>.Instance.ProcessPacketBytes(bytes);
if (channelNumber == SITGameServerClientDataProcessing.FLATBUFFER_CHANNEL_NUM)
{
Singleton<SITGameServerClientDataProcessing>.Instance.ProcessFlatBuffer(reader.GetRemainingBytes());
}
else
{
var bytes = reader.GetRemainingBytes();
Singleton<SITGameServerClientDataProcessing>.Instance.ProcessPacketBytes(bytes);
}
}

void OnDestroy()
Expand Down Expand Up @@ -282,9 +289,6 @@ public void SendData(byte[] data)
SendData(data, 0, data.Length, 0, LiteNetLib.DeliveryMethod.ReliableOrdered);
}


// Send(byte[] data, int start, int length, byte channelNumber, DeliveryMethod deliveryMethod)

public void SendData<T>(ref T packet) where T : BasePacket
{
using NetDataWriter writer = new NetDataWriter();
Expand Down
3 changes: 0 additions & 3 deletions Source/Networking/SITGameServerClientDataProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
{
public class SITGameServerClientDataProcessing : NetworkBehaviour
{
public const string PACKET_TAG_METHOD = "m";
public const string PACKET_TAG_SERVERID = "serverId";
public const string PACKET_TAG_DATA = "data";
public const byte FLATBUFFER_CHANNEL_NUM = 1;
public event Action<ushort> OnLatencyUpdated;

Check warning on line 29 in Source/Networking/SITGameServerClientDataProcessing.cs

View workflow job for this annotation

GitHub Actions / Build-SIT (Debug)

The event 'SITGameServerClientDataProcessing.OnLatencyUpdated' is never used
private SITGameComponent SITGameComponent { get; set; }

public ManualLogSource Logger { get; set; }
Expand Down
Loading