Skip to content

client callback OnDisconnected always being called twice #126

Open

Description

@PyrateAkananto

The intention of pull #121 from @imerr was to have the callback client.OnDisconnected being called within the client even in case of socket errors or different exceptions.

I think that intention was fulfilled. This can be verified for example by calling client.Connect("localhost", 13378888); which uses an invalid port.

On the other hand I think that the change had unintended side effects. In my project I can see that within the client during regular, error-free use the callback client.OnDisconnected is always called twice. It does not matter whether the client or the server initiated the disconnect.

In my opinion that callback should only be called once (not twice).

My knowledge about Telepathy is not good enough to suggest an improvement or even create a pull request, sorry.

Activity

  1. marek-stoj commented on Jun 26, 2023

    @marek-stoj

    I've encountered the same issue. I think that the #121 change is incorrect. I'm getting the Disconnected event without it. Just make sure to always call client.Tick() in the Unity's Update loop even if the client is not connecting/connected. Maybe that was the root cause of @imerr's issue that prompted him to implement that "fix" (?)

  2. noxowl commented on Oct 3, 2023

    @noxowl

    Do we have a solution yet?

  3. PyrateAkananto commented on Nov 14, 2023

    @PyrateAkananto
    ContributorAuthor

    #121 is listed in the change log of V1.9 (cbdf3dc).

  4. samserious25 commented on Sep 26, 2024

    @samserious25

    If you want to fix it, try to remove line 178 from Client.cs. Telepathy add this message to queue when disconnecting from server and closing thread. I think it's too much for this

    // add 'Disconnected' event to receive pipe so that the caller
    // knows that the Connect failed. otherwise they will never know
    state.receivePipe.Enqueue(0, EventType.Disconnected, default);

    Fix me If I am wrong

    So when client is unable to connect to server, this event wont be invoked. You choose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions