require "io/hexdump" def print_hexa(message : String, aroundmsg : String) puts "#{aroundmsg} [[" m = IO::Memory.new(message) io = IO::Hexdump.new(m, output: STDERR, read: true) buffer = Bytes.new 4000 io.read (buffer) # reading = should print puts "]] #{aroundmsg}" end # str = to_message(42, "coucou") # print_hexa str, "message sent" # ws.send str