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

Send a message without copying payload #51

Closed
zpostfacto opened this issue Jan 28, 2019 · 0 comments
Closed

Send a message without copying payload #51

zpostfacto opened this issue Jan 28, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@zpostfacto
Copy link
Contributor

Our API for receiving messages is efficient right now in that it avoids copying the payload, and also returns multiple messages at once, reducing the per-call overhead.

We should make a similar API for sending a message. The app would fill out a buffer and a message structure (or multiple such structures) and then pass them all off to the API to be dispatched at once.

The main sticking point is in the management of the buffer. Probably the app would provide a callback function to free their buffer. But I think we want to always allocate the actual message structures.

@zpostfacto zpostfacto added the enhancement New feature or request label Jan 28, 2019
@zpostfacto zpostfacto self-assigned this Jan 29, 2019
zpostfacto added a commit that referenced this issue Jan 30, 2019
Moved them to ISteamNetworkingUtils, which is now actually shared Steam (mostly) with a real accessor and and interface, and not a dummy interface object with all static methods.

Connection settings have a system of inheritance, so they can be set globally, per SteamNetworkingSockets interface, per listen socket, or per connection.

Deleted the config variable to simulate fake *message* loss.  That is not useful.

Introduced STEAMNETWORKINGSOCKETS_ENABLE_SDR define, to make it more clear why code is being #ifdef'ed out.  (E.g. if we open-sourced that code, we would want that included.)

Replaced ESteamNetworkingSendType with a basic flags bitmask.

Cleaned up a bunch of comments.

Changed SteamNetworkingMessage_t release mechanism.  Now the callback is only to free the buffer, and it's assumed that this API will manage the actual objects.  (This is important because the actual type is a derived type and has extra stuff on the end.)  Also laid some groundwork for user management of message objects.  (Relevant for issue #51.)
zpostfacto added a commit that referenced this issue Sep 19, 2019
Working towards being able to use this object in a new API to send messages
efficiently.  (Issue #51.)

- Message objects are actually ref counted now.
- m_sender renamed to m_identityPeer
- Added a flags field.  Now you can know if the received message was sent
  reliable or not.
- Added inline protected destructor to enforce proper usage.
- Tweaked tons of comments
- When receiving a fragmented unreliable message, I found a place where we
  were doing more memory allocations and memcpying than necessary and
  optimized that.

Delete a #ifdef __cplusplus block.  This whole file is using tons of C++
features.  It was weird to have that one block have that #ifdef

Also: In ConnectionState_ProblemDetectedLocally and ConnectionState_FinWait,
don't try to take any action immediately.  Just trigger an immediate wake up
call, and we will take that action back out in the main loop, where we know
what's higher up on the call stack and what is safe to do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant