[ENet-discuss] Help! Questions about using enet in a gameserver.

Lee Salzman 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
connected peers.

On Mon, Jun 4, 2012 at 8:26 PM, 张鹏飞 <zhangpengfei at red-infinity.com> wrote:

> **
> Hi,
>
> 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
> client?
> 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
> pointer.
>
> 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!
>
> Thanks,
> Kevin.
>
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20120604/5c40c306/attachment.html>


More information about the ENet-discuss mailing list