3
0
websocketd/src/utils.cr
2020-07-04 22:31:17 +02:00

15 lines
358 B
Crystal

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