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

disconnect event has no peer data #270

Open
winsvega opened this issue Nov 25, 2024 · 1 comment
Open

disconnect event has no peer data #270

winsvega opened this issue Nov 25, 2024 · 1 comment

Comments

@winsvega
Copy link

winsvega commented Nov 25, 2024

Apparently when using

while (enet_host_service(m_server, &event, 0) > 0)
{
        switch (event.type)
        {
              case ENET_EVENT_TYPE_DISCONNECT:
        }
}
``

an event comes with peer data removed. 
so event.peer->data   is 0
event.peer->connectionID is 0
all is nulled and I have no way to tell who has disconnected.

the workaround is to store a map of peer pointers in memory itself represented as int or str. 
@lunarlattice0
Copy link

I think event.peer ->data should still be valid on disconnect; you still need to clean up if you have modified it.

An event of type ENET_EVENT_TYPE_DISCONNECT is returned when a connected peer has either explicitly disconnected or timed out. Only the "peer" field of the event structure is valid for this event and contains the peer that disconnected. Only the "data" field of the peer is still valid on a disconnect event and must be explicitly reset.
from http://enet.bespin.org/Tutorial.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants