Module: Aiwolf::Base

Includes:
CommandParser, Logger, EventMachine::Protocols::LineProtocol
Included in:
Client
Defined in:
lib/aiwolf/base.rb,
lib/aiwolf/base/try.rb,
lib/aiwolf/base/logger.rb,
lib/aiwolf/base/command_parser.rb

Defined Under Namespace

Modules: CommandParser, Logger, Try

Instance Attribute Summary

Attributes included from Logger

#logger

Instance Method Summary collapse

Methods included from CommandParser

#parse_command

Instance Method Details

#receive_line(data) ⇒ Object



13
14
15
16
17
18
# File 'lib/aiwolf/base.rb', line 13

def receive_line(data)
  logger.debug(data)
  result = parse_command(JSON.parse(data, symbolize_names: true))
  logger.debug(result)
  send_data("#{result}\n") unless result.nil? || result.empty?
end

#unbindObject



20
21
22
23
# File 'lib/aiwolf/base.rb', line 20

def unbind
  logger.debug('connection closed')
  EventMachine.stop_event_loop
end