[ENet-discuss] How to temporarily keep a host from accepting incoming connection requests?
Benoit Germain
bgermain at ubisoft.fr
Thu Jun 17 02:45:26 PDT 2010
Hello,
I have a situation where I want a host to communicate with remote peers normally, while at the same time ignoring incoming connection requests. I could of course put my application in a mode where I disconnect immediately peers for which I receive a CONNECT event, but I'd rather leave the peers alone and make sure I get connect events when I am ready to accept them. I was thinking that I could "short-circuit" connect commands. This could be made with a rudimentary password mechanism, as such (of course this requires the new connect data introduced in 1.3.0):
Add this in the host structure (and add proper initialization where required)
Typedef struct _EnetHost
{
...
enet_uint32 sessionPassword;
};
Add the following at the beginning of enet_protocol_handle_connect():
switch( host-> sessionPassword)
{
case 0: // session is opened, proceed
break;
case 0xffffffff: // session is locked, ignore all requests
return NULL;
default: // session is password-protected, proceed only if incoming request data matches password
if( ENET_NET_TO_HOST_32( command->connect.data) != host->sessionPassword)
return NULL;
}
Is this the proper place and way to do what I want, or should I expect bad things from this?
Regards,
Benoit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20100617/a83e8d8a/attachment.html>
More information about the ENet-discuss
mailing list