Sha256: e40350ca65660fab2e5d4d062ac6f17c0d95b57b80a44876d203c510adc2499f

Contents?: true

Size: 664 Bytes

Versions: 8

Compression:

Stored size: 664 Bytes

Contents

require "fileutils"

module Invoker
  module CommandListener
    class Server
      SOCKET_PATH = "/tmp/invoker"
      def initialize
        @open_clients = []
        Socket.unix_server_loop(SOCKET_PATH) {|sock, client_addrinfo|
          begin
            process_client(sock)
          ensure
            sock.close
          end
        }
      end

      def clean_old_socket
        if File.exists?(SOCKET_PATH)
          FileUtils.rm(SOCKET_PATH, :force => true)
        end
      end

      def process_client(client_socket)
        client = Invoker::CommandListener::Client.new(client_socket)
        client.read_and_execute
      end
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
invoker-1.0.4 lib/invoker/command_listener/server.rb
invoker-1.0.3 lib/invoker/command_listener/server.rb
invoker-1.0.2 lib/invoker/command_listener/server.rb
invoker-1.0.1 lib/invoker/command_listener/server.rb
invoker-1.0.0 lib/invoker/command_listener/server.rb
invoker-0.1.2 lib/invoker/command_listener/server.rb
invoker-0.1.1 lib/invoker/command_listener/server.rb
invoker-0.1.1.pre lib/invoker/command_listener/server.rb