mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
Merge branch 'main' into debugging-client
This commit is contained in:
commit
fbc9ceece4
8 changed files with 86 additions and 18 deletions
|
|
@ -13,11 +13,13 @@ enum NetworkEventType {
|
|||
CONNECTED_TO_SERVER,
|
||||
DATAGRAM,
|
||||
RESPONSE,
|
||||
CONNECTION_ERROR,
|
||||
};
|
||||
|
||||
struct ConnectionEventDto {
|
||||
u64id_t server;
|
||||
u64id_t client;
|
||||
std::string comment {};
|
||||
};
|
||||
|
||||
struct ResponseEventDto {
|
||||
|
|
@ -283,6 +285,11 @@ static int l_connect_tcp(lua::State* L, network::Network& network) {
|
|||
CONNECTED_TO_SERVER,
|
||||
ConnectionEventDto {0, cid}
|
||||
));
|
||||
}, [](u64id_t cid, std::string errorMessage) {
|
||||
push_event(NetworkEvent(
|
||||
CONNECTION_ERROR,
|
||||
ConnectionEventDto {0, cid, std::move(errorMessage)}
|
||||
));
|
||||
});
|
||||
return lua::pushinteger(L, id);
|
||||
}
|
||||
|
|
@ -439,7 +446,8 @@ static int l_pull_events(lua::State* L, network::Network& network) {
|
|||
const auto& event = local_queue[i];
|
||||
switch (event.type) {
|
||||
case CLIENT_CONNECTED:
|
||||
case CONNECTED_TO_SERVER: {
|
||||
case CONNECTED_TO_SERVER:
|
||||
case CONNECTION_ERROR: {
|
||||
const auto& dto = std::get<ConnectionEventDto>(event.payload);
|
||||
lua::pushinteger(L, event.type);
|
||||
lua::rawseti(L, 1);
|
||||
|
|
@ -449,6 +457,9 @@ static int l_pull_events(lua::State* L, network::Network& network) {
|
|||
|
||||
lua::pushinteger(L, dto.client);
|
||||
lua::rawseti(L, 3);
|
||||
|
||||
lua::pushlstring(L, dto.comment);
|
||||
lua::rawseti(L, 4);
|
||||
break;
|
||||
}
|
||||
case DATAGRAM: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue