FirstGearGames / FishySteamworks

A Steamworks implementation for Fish-Net.
Other
80 stars 18 forks source link

GetConnectionState problem #5

Open makcimbx opened 1 year ago

makcimbx commented 1 year ago

Hi, I am using GetConnectionState after StartConnection for the client to monitor the connection status and it always returns Stopped. If you start the server, it works fine. Same problem with Facepunch transporter. UnityTransporter and Tugboat work fine with this method on client connection startup.

makcimbx commented 1 year ago

Just in case. @FirstGearGames

FirstGearGames commented 10 months ago

Are you calling it immediately after StartConnection or polling it continuously and it still returning Stopped even though started?

makcimbx commented 10 months ago

I use this code for Tugboat, Unity and Yak transports. UniTask checks the given condition every frame. But it is not working for Steam transport.

public virtual async UniTask StartClient()
{
    multipass.StartConnection(false, transportIndex);

    await UniTask.WaitUntil(() =>
        multipass.GetConnectionState(false, transportIndex) == LocalConnectionState.Started);
}

I end up having to use this code to check that the client has connected on Steam transport.

public override async UniTask StartClient()
{
    var completionSource = new UniTaskCompletionSource();

    networkManager.ClientManager.OnClientConnectionState += OnClientConnectionState;

    multipass.StartConnection(false);

    await completionSource.Task;

    void OnClientConnectionState(ClientConnectionStateArgs args)
    {
        if (args.ConnectionState != LocalConnectionState.Started) return;
        networkManager.ClientManager.OnClientConnectionState -= OnClientConnectionState;
        completionSource.TrySetResult();
    }
}
FirstGearGames commented 2 months ago

I didn't see anything in the code that stood out. I'll have to run the transport to tests.