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

Would be nice if IListenWebSocketClient Send method allowed passing in buffer length #333

Closed
sgodin opened this issue Sep 24, 2024 · 3 comments

Comments

@sgodin
Copy link

sgodin commented Sep 24, 2024

Proposed changes

Send API currently looks like:
void Send(byte[] data);

Since it eventually copies this buffer to the websocket message, it would be ideal if the API had an optional buffer size/length parameter, ie: something like:
void Send(byte[] data, int dataLen=0);
If 0 is passed in then data.Length is used.

Context

The code I used to read from the stream (ie: stream.ReadAsync) requires a buffer to be created first and returns the number of bytes read. In order to pass this buffer to Deepgram C# API, I need to copy it to another array that is sized as the number of bytes actually read, not the size of the passed in buffer. If the API had this option I could avoid a copy and it would be more efficient.

@davidvonthenen
Copy link
Contributor

Hi @sgodin

That's a good idea. Will get that incorporated in the next release.

@davidvonthenen
Copy link
Contributor

PR #334 merged. Will be available in the 4.3.4 release.

@sgodin
Copy link
Author

sgodin commented Sep 26, 2024

Awesome - thanks!

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

2 participants