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

Suggestions; adding the following to ENetHost references in Lua. #7

Open
fleetcomm opened this issue Jun 25, 2013 · 0 comments
Open

Comments

@fleetcomm
Copy link

/* returns a string referencing the printable ip address of the current host /
static int host_get_address(lua_State
l)
{
ENetHost *host = check_host(l, 1);
std::string address;
char buff[1024];
enet_address_get_host_ip(&host->address, buff, 1024);
address.clear();
address.append(buff);
lua_pushstring(l, address.c_str());
return 1;
}

/* and in function registry */

static const struct luaL_Reg enet_host_funcs [] =
{
{"service", host_service},
{"check_events", host_check_events},
{"compress_with_range_coder", host_compress_with_range_coder},
{"connect", host_connect},
{"flush", host_flush},
{"broadcast", host_broadcast},
{"channel_limit", host_channel_limit},
{"bandwidth_limit", host_bandwidth_limit},
{"total_sent_data", host_total_sent_data},
{"total_received_data", host_total_received_data},
{"service_time", host_service_time},
{"peer_count", host_peer_count},
{"get_peer", host_get_peer},
{"get_address", host_get_address},
{NULL, NULL}
};

If you find this useful, please add it. I'm currently using that add on function to run local server auto detection.

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

1 participant