Class: Del::SocketConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/del/socket_connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(path:) ⇒ SocketConnection

Returns a new instance of SocketConnection.



5
6
7
8
# File 'lib/del/socket_connection.rb', line 5

def initialize(path:)
  File.unlink(path) if File.exist?(path)
  @server = UNIXServer.new(path)
end

Instance Method Details

#on_receiveObject



10
11
12
13
14
15
16
17
# File 'lib/del/socket_connection.rb', line 10

def on_receive
  socket = @server.accept
  yield socket
rescue StandardError => error
  Del.logger.error(error)
ensure
  socket&.close
end