Knot::Protocol#snd supports strings as key, too (calls to_sym)
This commit is contained in:
parent
59db51d2ed
commit
12639f766c
|
@ -183,21 +183,13 @@ class Knot::Protocol
|
||||||
|
|
||||||
def snd sock: nil, **data
|
def snd sock: nil, **data
|
||||||
rsock = sock || @sock
|
rsock = sock || @sock
|
||||||
#s = ''.b
|
data = Hash[ *data.map {|k,v| [k.to_sym, v]}.flatten]
|
||||||
#sock = StringIO.new s
|
|
||||||
#sock.write [1].pack( 'c')
|
|
||||||
data[:flags] ||= ''
|
data[:flags] ||= ''
|
||||||
ds =
|
ds =
|
||||||
Idx.
|
Idx.
|
||||||
select {|n| data[n.to_sym] }.
|
select {|n| p [n.to_sym, data[n.to_sym]]; data[n.to_sym] }.
|
||||||
map {|n| v = data[n.to_sym].to_s.b; [n.to_i, v.size, v] }
|
map {|n| v = data[n.to_sym].to_s.b; [n.to_i, v.size, v] }
|
||||||
s = [Types[:data].to_i, ds, Types[:block].to_i].flatten.pack( "c #{'c na*'*ds.length} c").b
|
s = [Types[:data].to_i, ds, Types[:block].to_i].flatten.pack( "c #{'c na*'*ds.length} c").b
|
||||||
#Idx.each do |n|
|
|
||||||
# v = data[n.to_sym]&.to_s&.b
|
|
||||||
# sock.write [n.to_i, v.size, v].pack( 'c na*') if v
|
|
||||||
#end
|
|
||||||
#sock.write [3].pack( 'c')
|
|
||||||
#sock.flush
|
|
||||||
if 0 >= @logger.sev_threshold
|
if 0 >= @logger.sev_threshold
|
||||||
@logger.debug "send data #{data.inspect}"
|
@logger.debug "send data #{data.inspect}"
|
||||||
@logger.debug "send raw #{s.inspect}"
|
@logger.debug "send raw #{s.inspect}"
|
||||||
|
|
Loading…
Reference in a new issue