Module: Arbi::Server::Server

Defined in:
lib/arbi/server.rb

Instance Method Summary collapse

Instance Method Details

#post_initObject



27
28
29
# File 'lib/arbi/server.rb', line 27

def post_init
  send_data("OH HAI! ^_^\n")
end

#receive_data(data) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/arbi/server.rb', line 31

def receive_data(data)
  if data.strip.downcase =~ /^(quit|exit)$/
    close_connection
    return
  end

  obj = Arbi.modules[data.strip.downcase]

  if obj
    send_data(obj.to_json)
  else
    send_data(Arbi::Modules::Error.new('Command doesn\'t exist').to_json)
  end
rescue Exception => e
  Arbi.debug(e.to_s)
end