zpl-c/librg

LIBRG_CONNECTION_ACCEPT payload

markatk opened this issue · 2 comments

When the server accepts a client connection, it would be nice for the server to be able to send data to the client with the LIBRG_CONNECTION_ACCEPT event for initial setup (for example to set the initial position or health).

Actually, this feature is already implemented.
https://github.com/librg/librg/blob/master/include/librg.h#L2249-L2260

As you see, the event will be triggered just before sending the packet, and even does contain a pointer to the data, so you can potentially write some data into it.

Ah, I see now. I thought the callback is executed AFTER sending the event to the client, but actually it's called BEFORE the actual sending. I think I was confused by the name callback, since it is used for functions to be called after something happens in most places.
Anyways, great news for me 👍