class Necro::CommandListener::Server

Constants

SOCKET_PATH

Public Class Methods

new() click to toggle source
# File lib/necro/command_listener/server.rb, line 7
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

Public Instance Methods

clean_old_socket() click to toggle source
# File lib/necro/command_listener/server.rb, line 18
def clean_old_socket
  if File.exists?(SOCKET_PATH)
    FileUtils.rm(SOCKET_PATH, :force => true)
  end
end
process_client(client_socket) click to toggle source
# File lib/necro/command_listener/server.rb, line 24
def process_client(client_socket)
  client = Necro::CommandListener::Client.new(client_socket)
  client.read_and_execute
end