Sha256: 989c2b81de3af09cb5e8805b741625c726fbed363f6cd3cb1add32de18768b66
Contents?: true
Size: 787 Bytes
Versions: 5
Compression:
Stored size: 787 Bytes
Contents
module CQHTTP # TODO class Service attr_reader :json def initialize(hostname: '0.0.0.0', port: 9455) @server = TCPServer.new(hostname, port) @event_method = [] end def bind(func) @event_method << func end def run loop do socket = @server.accept head socket socket.print "HTTP/1.1 204\r\nContent-Type: application/json\r\n\r\n" data = socket.gets @json = JSON.parse data @event_method.each { |func| func.call self } socket.close end end private def head(socket) puts 'head' if $VERBOSE while (line = socket.gets) != "\r\n" print ' ' if $VERBOSE puts line if $VERBOSE end puts 'end' if $VERBOSE end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
CQHTTP-2.2.1 | lib/CQHTTP/service.rb |
CQHTTP-2.2.0 | lib/CQHTTP/service.rb |
CQHTTP-2.1.0 | lib/CQHTTP/service.rb |
CQHTTP-2.0.0 | lib/CQHTTP/service.rb |
CQHTTP-1.1.1 | lib/CQHTTP/service.rb |