SwiftPhoenixClient icon indicating copy to clipboard operation
SwiftPhoenixClient copied to clipboard

Sending binary data in a message

Open msandel6 opened this issue 2 years ago • 4 comments

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.

msandel6 avatar Jun 29 '23 16:06 msandel6

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

dsrees avatar Jul 03 '23 00:07 dsrees

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.

samrat avatar Feb 20 '24 23:02 samrat

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

dsrees avatar Feb 24 '24 01:02 dsrees