Skip to content

Calling SendMessage() through a NetworkPeer with a custom INetworkDriver C# implementation fails when sending multiple NetworkConnection targets #3649

@envision3d

Description

@envision3d

While working on Steam network connectivity via Tryibion's Steamworks plugin, I discovered a problem with how the driver is working within Flax. It seems the implemented method for sending a message to multiple targets doesn't get invoked.

Peer code:

var message = localNetworkPeer.BeginSendMessage();
localNetworkPeer.EndSendMessage(channelType, message, networkConnections); // networkConnections is NetworkConnection[]

Driver code that should be invoked, but is not:
https://github.com/Tryibion/FlaxFacepunchSteamworks/blob/c21b9e9e07c411b4dff25560283f98beb9907130/Source/FacepunchSteamworks/FacepunchNetworkDriver.cs#L222

Along the way trying to diagnose the problem, I added the following code to attempt to hijack the call and discover how the parameters were being seen by putting this method in the driver:

public void SendMessage(NetworkChannelType channelType, NetworkMessage message, object targets)
{
    Debug.Log($"[!!!] Targets type: {targets.GetType()}");
}

// result:
[ 00:06:38.217 ]: [Info] [!!!] Targets type: FlaxEngine.Interop.ManagedArray

It seems the code that prepares the NetworkConnection[] for this variant of SendMessage() has a bug, and thus the desired method doesn't get invoked.

Maybe worth noting: the other SendMessage() variants seem to be working properly.
Also worth noting, if I call the SendMessage() method with multiple targets directly on the driver, it works fine; it only fails when called through the NetworkPeer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions