Sha256: dbbed9c267c16a689fb2ba22afb5bc7d573c2e7d6827745379cb9e49e0efcffb

Contents?: true

Size: 365 Bytes

Versions: 3

Compression:

Stored size: 365 Bytes

Contents

# frozen_string_literal: true

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
del-0.1.19 lib/del/socket_connection.rb
del-0.1.18 lib/del/socket_connection.rb
del-0.1.17 lib/del/socket_connection.rb