Class: EventedBluepill::Socket::CmdListenerConnection

Inherits:
Coolio::UNIXSocket
  • Object
show all
Defined in:
lib/evented_bluepill/socket.rb

Instance Method Summary collapse

Constructor Details

#initialize(socket, application) ⇒ CmdListenerConnection

Returns a new instance of CmdListenerConnection.



11
12
13
14
# File 'lib/evented_bluepill/socket.rb', line 11

def initialize(socket, application)
  @application = application
  super(socket)
end

Instance Method Details

#on_read(data) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/evented_bluepill/socket.rb', line 16

def on_read(data)
  command, *args = data.strip.split(":")
  response = begin
    @application.send(command, *args)
  rescue Exception => e
    e
  end
  write(Marshal.dump(response))
end