Sha256: 0c17f7b8c2b8526711ac1274ea350fa7a382cf04cb5eabdc27ce70441ea170b6

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 Bytes

Contents

require "fileutils"

module Necro
  module CommandListener
    class Server
      SOCKET_PATH = "/tmp/necro"
      def initialize
        @open_clients = []
        clean_old_socket()
        UNIXServer.open(SOCKET_PATH) do |client|
          loop do
            client_socket = client.accept
            process_client(client_socket)
          end
        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 = Necro::CommandListener::Client.new(client_socket)
        client.read_and_execute
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
necro-0.0.2 lib/necro/command_listener/server.rb