diff --git a/ruby-sockets/line-protocol/client.rb b/ruby-sockets/line-protocol/client.rb index b384121..460116b 100644 --- a/ruby-sockets/line-protocol/client.rb +++ b/ruby-sockets/line-protocol/client.rb @@ -21,9 +21,9 @@ def main sock.close puts "raw response --> #{response.inspect}" - code = response[0..30].to_s.strip - num = response[31..42].to_s.strip - raw_timestamp = response[49..62].to_s.strip + code = response[0,31].to_s.strip + num = response[31,12].to_s.strip + raw_timestamp = response[49,14].to_s.strip timestamp = DateTime.strptime(raw_timestamp, DATEFMT) puts "code: '#{code}'" diff --git a/ruby-sockets/line-protocol/server.rb b/ruby-sockets/line-protocol/server.rb index 6a52f9f..0b47598 100644 --- a/ruby-sockets/line-protocol/server.rb +++ b/ruby-sockets/line-protocol/server.rb @@ -18,12 +18,12 @@ module LineProtocolServer end def receive_data(request) - code = request[0..30].to_s.strip - num = request[31..42].to_s.strip - len = request[43..48].to_s.strip - puts "raw date --> '#{request[49..62]}'" - timestamp = DateTime.strptime(request[49..62].strip, DATEFMT) - msg = request[63..(63 + len.to_i)].strip + code = request[0,31].to_s.strip + num = request[31,12].to_s.strip + len = request[43,6].to_s.strip + puts "raw date --> '#{request[49,14]}'" + timestamp = DateTime.strptime(request[49,14].strip, DATEFMT) + msg = request[63,len.to_i+1].strip puts "code: '#{code}'" puts "num: '#{num}'"