[ENet-discuss] Help! Questions about using enet in a gameserver.
lsalzman at gmail.com
Mon Jun 4 20:48:46 PDT 2012
You do not delete the peers, ENet handles the management of this. The peers
array is allocated once when you create a host, up to the maximum number of
peers you specified then, and only ever deleted when you delete the host.
All ENet does is change the variables in this peer to reflect the
connection status. This peers array is accessible in the host->peers field.
However, if you need to send a packet to all or some subset or these peers,
it is still probably better that you manage that yourself, as ENet does not
keep these peers in any particular order. So if you have a large number of
peers pre-allocated, iterating over this array for only those connected
peers might not be very efficient relative to just keeping a list of
On Mon, Jun 4, 2012 at 8:26 PM, 张鹏飞 <zhangpengfei at red-infinity.com> wrote:
> We are developing a fps game server, and trying to use enet. There are
> some questions that I can't find any clue in enet document or google. I
> really need your help.
> Does server need to store all ENetPeer objects in
> "ENET_EVENT_TYPE_CONNECT" event, so that server can send packet to any
> If so, what's the life cycle of a ENetPeer object? Will enet delete this
> object itself after event "ENET_EVENT_TYPE_DISCONNECT" occurred, or I
> should delete it in my code?
> If it will be deleted automatically, is there any way that I can know
> this? Otherwise the pointer to the ENetPeer object I stored become a wild
> I've know how to use enet in the simplest way after
> read the tutorial, but it's far from enough to implement a real server.
> If there is some sample code of server side, or detailed document, it will
> help very much.
> Any suggestion is appreciated!
> ENet-discuss mailing list
> ENet-discuss at cubik.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ENet-discuss