From mman at martinman.net Mon Mar 18 18:53:13 2024 From: mman at martinman.net (Martin Man) Date: Mon, 18 Mar 2024 19:53:13 +0100 Subject: [ENet-discuss] Question about enet_host_connect/enet_peer_disconnect data Message-ID: Hi Lee, others? I have noticed something undocumented that I am wondering about? When you enet_host_connect to another peer and pass in the data parameter of X? that constant X gets passed to the remote event ENET_EVENT_TYPE_CONNECT as expected. However on the local host where the connect originated, the ENET_EVENT_TYPE_CONNECT receives 0. Similarly, when you enet_peer_disconnect with custom data value X, that value X gets transmitted to the remote side and propagated up via ENET_EVENT_TYPE_DISCONNECT, but originating host receives the event with 0. I am just wondering what is the thinking behind this feature. I have gotten the feeling that the same X passed to _connect and _disconnect should be propagated on both sides? Could you please help me understand this? thanks, Martin From bjorn at lindeijer.nl Mon Mar 18 19:45:09 2024 From: bjorn at lindeijer.nl (=?UTF-8?Q?Thorbj=C3=B8rn_Lindeijer?=) Date: Mon, 18 Mar 2024 20:45:09 +0100 Subject: [ENet-discuss] Question aboutenet_host_connect/enet_peer_disconnect data In-Reply-To: References: Message-ID: On Mon, Mar 18, 2024, at 19:53, Martin Man wrote: > When you enet_host_connect to another peer and pass in the data > parameter of X? that constant X gets passed to the remote event > ENET_EVENT_TYPE_CONNECT as expected. However on the local host where > the connect originated, the ENET_EVENT_TYPE_CONNECT receives 0. > > Similarly, when you enet_peer_disconnect with custom data value X, that > value X gets transmitted to the remote side and propagated up via > ENET_EVENT_TYPE_DISCONNECT, but originating host receives the event > with 0. > > I am just wondering what is the thinking behind this feature. I have > gotten the feeling that the same X passed to _connect and _disconnect > should be propagated on both sides? The data parameter is documented as follows: "user data supplied to the receiving host". So at least it appears to be working as documented. With the current behavior for the ENET_EVENT_TYPE_CONNECT and ENET_EVENT_TYPE_DISCONNECT events, we can rely on "data" always being whatever the remote host has sent us when connecting / disconnecting, or 0 when it didn't send anything. That's different from having to handle a "data" value that could have originated either from the remote host or from the local host. Also, ENet already provides a mechanism for sharing data locally, it being the data pointer in the ENetPeer structure. So if you need your connect / disconnect data locally, you could store it in the custom peer data instead. I hope this helps. :-) Cheers, Thorbj?rn