mist icon indicating copy to clipboard operation
mist copied to clipboard

WebSocket Builder Messages

Open varnerac opened this issue 2 years ago • 4 comments

Mist currently supports binary and string messages. It'd make sense to support StringBuilder and BitBuilder outgoing messages.

varnerac avatar Jan 12 '23 13:01 varnerac

Not sure if I'm misunderstanding your ask here, but it currently supports BitBuilder as the "data" type only. You can easily call bit_builder.from_string_builder to get that out of it, so I'm not sure how much value that would provide? It'd be another custom type variant on the response, that would end up just doing that function call anyway.

Please let me know if I am indeed misunderstanding :)

rawhat avatar Jan 31 '23 21:01 rawhat

For WebSockets I'd like to see something like:

pub type Message {
  BinaryMessage(data: BitString)
  BitBuilderMessage(data: BitBuilder)
  TextMessage(data: String)
  StringBuilderMessage(data: StringBuilder)
}

so I could:

let data: StringBuilder = my_codec.build()
let Nil = websocket.send(subject, StringBuilderMessage(data: data)

The alternative is to take my StringBuilder, convert it to a String, pass it in as a TextMessage, and have Mist convert it to a BitBuilder. I'd like to keep stuff as iodata() rather than have Mist convert it back and forth.

varnerac avatar Feb 01 '23 14:02 varnerac

Ah, sorry! I somehow managed to miss the obvious WebSocket in the title of the issue... that seems very reasonable to me. Should be a small change! Thank you 😃

rawhat avatar Feb 02 '23 01:02 rawhat

You didn't miss it. I edited the title today when I realized it was unclear.

varnerac avatar Feb 02 '23 01:02 varnerac