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

Sending binary data in a message #244

Open
msandel6 opened this issue Jun 29, 2023 · 4 comments
Open

Sending binary data in a message #244

msandel6 opened this issue Jun 29, 2023 · 4 comments

Comments

@msandel6
Copy link
Contributor

Issue:

I'm trying to send some messages to the server that contain binary data instead of JSON. I might be missing something, but so far it looks to me like the framework doesn't support sending an event with anything other than JSON as a payload.

Possible solution:

I took an initial pass at what might be needed to support sending binary data using the URLSessionWebSocketTask.Message.data(Data) function. Unfortunately, it looks to me like this would require a new/updated implementation of Push because the current one only allows payloads of type [String : Any] to be passed in for transport. Can you think of a more straightforward approach?

I believe sending events with binary data payloads is a pretty commonly used Phoenix feature, so I think this would add general value to the framework. I'll keep working on a possible solution on my end, but curious to hear your thoughts @dsrees.

@dsrees
Copy link
Collaborator

dsrees commented Jul 3, 2023

Correct, the client does not currently support receiving or sending binary data. Its actually something I've been looking into recently to add. I'll update if I make any progress on this feature

@samrat
Copy link

samrat commented Feb 20, 2024

Hi, was there any progress on this issue? My use-case involves sending audio samples so would be great to not have to pay the JSON serialization/deserialization cost.

@dsrees
Copy link
Collaborator

dsrees commented Feb 24, 2024

@samrat something is in the works. I'll update back here when progress is made

@dsrees
Copy link
Collaborator

dsrees commented Nov 13, 2024

#273 added support to the 6.x branch to push binary data through a channel

channel.binaryPush("event", payload: Data())

6.x is still every much under development and further changes will be coming but let me know if anyone tries it out. I'll post back here when it has been released

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

3 participants