allow for polling methods to return events

main
Dominik Madarász 2023-08-21 18:35:22 +02:00
parent 27b580dbd2
commit 849b7cfef7
7 changed files with 113 additions and 98 deletions

View File

@ -2125,8 +2125,8 @@ enum { NETWORK_USERID = 5, NETWORK_COUNT , NETWORK_CAPACITY };
void network_rpc_send_to(int64_t rank, unsigned id, const char *cmdline);
void network_rpc_send(unsigned id, const char *cmdline);
bool server_bind(int max_clients, int port);
void server_poll(unsigned timeout_ms);
void client_poll(unsigned timeout_ms);
char** server_poll(unsigned timeout_ms);
char** client_poll(unsigned timeout_ms);
void server_broadcast_bin_flags(const void *ptr, int len, uint64_t flags);
void server_broadcast_bin(const void *ptr, int len);
void server_broadcast_flags(const char *msg, uint64_t flags);

View File

@ -15960,8 +15960,8 @@ API void network_rpc_send(unsigned id, const char *cmdline);
// low-level api (sockets based)
API bool server_bind(int max_clients, int port);
API void server_poll(unsigned timeout_ms);
API void client_poll(unsigned timeout_ms);
API char** server_poll(unsigned timeout_ms);
API char** client_poll(unsigned timeout_ms);
API void server_broadcast_bin_flags(const void *ptr, int len, uint64_t flags);
API void server_broadcast_bin(const void *ptr, int len);
API void server_broadcast_flags(const char *msg, uint64_t flags);
@ -338834,8 +338834,6 @@ int enet_event_to_netsync(int ev) {
}
char** network_sync(unsigned timeout_ms) {
array_clear(events);
int64_t whoami = network_get(NETWORK_RANK);
bool is_server = whoami == 0;
bool is_client = !is_server;
@ -338875,12 +338873,12 @@ char** network_sync(unsigned timeout_ms) {
client_poll(timeout_ms);
}
array_push(events, NULL);
return events;
}
void server_poll(unsigned timeout_ms) {
char** server_poll(unsigned timeout_ms) {
array_clear(events);
if(timeout_ms < 2) timeout_ms = 2;
// network poll
@ -339012,9 +339010,13 @@ void server_poll(unsigned timeout_ms) {
if(msg) array_push(events, stringf("%d %s", enet_event_to_netsync(event.type), msg));
}
array_push(events, NULL);
return events;
}
void client_poll(unsigned timeout_ms) {
char** client_poll(unsigned timeout_ms) {
array_clear(events);
int64_t whoami = network_get(NETWORK_RANK);
if(timeout_ms < 2) timeout_ms = 2;
@ -339118,6 +339120,9 @@ void client_poll(unsigned timeout_ms) {
if(msg) array_push(events, stringf("%d %s", enet_event_to_netsync(event.type), msg));
}
array_push(events, NULL);
return events;
}
int network_event(const char *msg, int *errcode, char **errstr) {

View File

@ -372,8 +372,6 @@ int enet_event_to_netsync(int ev) {
}
char** network_sync(unsigned timeout_ms) {
array_clear(events);
int64_t whoami = network_get(NETWORK_RANK);
bool is_server = whoami == 0;
bool is_client = !is_server;
@ -413,12 +411,12 @@ char** network_sync(unsigned timeout_ms) {
client_poll(timeout_ms);
}
array_push(events, NULL);
return events;
}
void server_poll(unsigned timeout_ms) {
char** server_poll(unsigned timeout_ms) {
array_clear(events);
if(timeout_ms < 2) timeout_ms = 2;
// network poll
@ -550,9 +548,13 @@ void server_poll(unsigned timeout_ms) {
if(msg) array_push(events, stringf("%d %s", enet_event_to_netsync(event.type), msg));
}
array_push(events, NULL);
return events;
}
void client_poll(unsigned timeout_ms) {
char** client_poll(unsigned timeout_ms) {
array_clear(events);
int64_t whoami = network_get(NETWORK_RANK);
if(timeout_ms < 2) timeout_ms = 2;
@ -656,6 +658,9 @@ void client_poll(unsigned timeout_ms) {
if(msg) array_push(events, stringf("%d %s", enet_event_to_netsync(event.type), msg));
}
array_push(events, NULL);
return events;
}
int network_event(const char *msg, int *errcode, char **errstr) {

View File

@ -57,8 +57,8 @@ API void network_rpc_send(unsigned id, const char *cmdline);
// low-level api (sockets based)
API bool server_bind(int max_clients, int port);
API void server_poll(unsigned timeout_ms);
API void client_poll(unsigned timeout_ms);
API char** server_poll(unsigned timeout_ms);
API char** client_poll(unsigned timeout_ms);
API void server_broadcast_bin_flags(const void *ptr, int len, uint64_t flags);
API void server_broadcast_bin(const void *ptr, int len);
API void server_broadcast_flags(const char *msg, uint64_t flags);

View File

@ -9849,8 +9849,6 @@ int enet_event_to_netsync(int ev) {
}
char** network_sync(unsigned timeout_ms) {
array_clear(events);
int64_t whoami = network_get(NETWORK_RANK);
bool is_server = whoami == 0;
bool is_client = !is_server;
@ -9890,12 +9888,12 @@ char** network_sync(unsigned timeout_ms) {
client_poll(timeout_ms);
}
array_push(events, NULL);
return events;
}
void server_poll(unsigned timeout_ms) {
char** server_poll(unsigned timeout_ms) {
array_clear(events);
if(timeout_ms < 2) timeout_ms = 2;
// network poll
@ -10027,9 +10025,13 @@ void server_poll(unsigned timeout_ms) {
if(msg) array_push(events, stringf("%d %s", enet_event_to_netsync(event.type), msg));
}
array_push(events, NULL);
return events;
}
void client_poll(unsigned timeout_ms) {
char** client_poll(unsigned timeout_ms) {
array_clear(events);
int64_t whoami = network_get(NETWORK_RANK);
if(timeout_ms < 2) timeout_ms = 2;
@ -10133,6 +10135,9 @@ void client_poll(unsigned timeout_ms) {
if(msg) array_push(events, stringf("%d %s", enet_event_to_netsync(event.type), msg));
}
array_push(events, NULL);
return events;
}
int network_event(const char *msg, int *errcode, char **errstr) {

View File

@ -2043,8 +2043,8 @@ API void network_rpc_send(unsigned id, const char *cmdline);
// low-level api (sockets based)
API bool server_bind(int max_clients, int port);
API void server_poll(unsigned timeout_ms);
API void client_poll(unsigned timeout_ms);
API char** server_poll(unsigned timeout_ms);
API char** client_poll(unsigned timeout_ms);
API void server_broadcast_bin_flags(const void *ptr, int len, uint64_t flags);
API void server_broadcast_bin(const void *ptr, int len);
API void server_broadcast_flags(const char *msg, uint64_t flags);

View File

@ -596,7 +596,7 @@ details > summary::-webkit-details-marker {
|Version: | 2023.7 |
|:--------------|:------------|
|Branch: | main |
|Commit: | 55 |
|Commit: | 56 |
<!--| Documentation last modified | { {LAST_MODIFIED} } |-->
# [V·4·K 2023.7 ](https://dev.v4.games/zaklaus/v4k)
@ -6693,7 +6693,7 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name="server_poll"></a>
<details><summary><code lang=C>🄵 API void server_poll(unsigned timeout_ms);</code></summary>
<details><summary><code lang=C>🄵 API char** server_poll(unsigned timeout_ms);</code></summary>
Under construction. Yet to be documented.
@ -6702,7 +6702,7 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name="client_poll"></a>
<details><summary><code lang=C>🄵 API void client_poll(unsigned timeout_ms);</code></summary>
<details><summary><code lang=C>🄵 API char** client_poll(unsigned timeout_ms);</code></summary>
Under construction. Yet to be documented.
@ -8644,8 +8644,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
## shaders
<a name=""></a>
<details><summary><code lang=C> extern const char* const fs_0_0_shadowmap_lit;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const fs_0_0_shadowmap_lit;</code></summary>
Under construction. Yet to be documented.
@ -8653,8 +8653,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const fs_0_0_shadowmap_unlit;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const fs_0_0_shadowmap_unlit;</code></summary>
Under construction. Yet to be documented.
@ -8662,8 +8662,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const fs_24_4_sprite;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const fs_24_4_sprite;</code></summary>
Under construction. Yet to be documented.
@ -8671,8 +8671,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const fs_2_4_preamble;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const fs_2_4_preamble;</code></summary>
Under construction. Yet to be documented.
@ -8680,8 +8680,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const fs_2_4_texel_inv_gamma;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const fs_2_4_texel_inv_gamma;</code></summary>
Under construction. Yet to be documented.
@ -8689,8 +8689,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const fs_2_4_texel_ycbr_gamma_saturation;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const fs_2_4_texel_ycbr_gamma_saturation;</code></summary>
Under construction. Yet to be documented.
@ -8698,8 +8698,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const fs_32_4_model;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const fs_32_4_model;</code></summary>
Under construction. Yet to be documented.
@ -8707,8 +8707,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const fs_32_4_model_basic;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const fs_32_4_model_basic;</code></summary>
Under construction. Yet to be documented.
@ -8716,8 +8716,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const fs_3_4_skybox;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const fs_3_4_skybox;</code></summary>
Under construction. Yet to be documented.
@ -8725,8 +8725,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const fs_3_4_skybox_rayleigh;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const fs_3_4_skybox_rayleigh;</code></summary>
Under construction. Yet to be documented.
@ -8734,8 +8734,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const fs_main_shadertoy;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const fs_main_shadertoy;</code></summary>
Under construction. Yet to be documented.
@ -8743,8 +8743,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const vs_0_2_fullscreen_quad_A;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const vs_0_2_fullscreen_quad_A;</code></summary>
Under construction. Yet to be documented.
@ -8752,8 +8752,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const vs_0_2_fullscreen_quad_B;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const vs_0_2_fullscreen_quad_B;</code></summary>
Under construction. Yet to be documented.
@ -8761,8 +8761,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const vs_0_2_fullscreen_quad_B_flipped;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const vs_0_2_fullscreen_quad_B_flipped;</code></summary>
Under construction. Yet to be documented.
@ -8770,8 +8770,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const vs_323444143_16_332_model;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const vs_323444143_16_332_model;</code></summary>
Under construction. Yet to be documented.
@ -8779,8 +8779,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const vs_324_24_sprite;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const vs_324_24_sprite;</code></summary>
Under construction. Yet to be documented.
@ -8788,8 +8788,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const vs_332_32;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const vs_332_32;</code></summary>
Under construction. Yet to be documented.
@ -8797,8 +8797,8 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
<a name=""></a>
<details><summary><code lang=C> extern const char* const vs_3_3_skybox;</code></summary>
<a name="rs.h""></a>
<details><summary><code lang=C>🄴 extern const char* const vs_3_3_skybox;</code></summary>
Under construction. Yet to be documented.