Class: Necro::CommandListener::Server
- Inherits:
-
Object
- Object
- Necro::CommandListener::Server
- Defined in:
- lib/necro/command_listener/server.rb
Constant Summary collapse
- SOCKET_PATH =
"/tmp/necro"
Instance Method Summary collapse
- #clean_old_socket ⇒ Object
-
#initialize ⇒ Server
constructor
A new instance of Server.
- #process_client(client_socket) ⇒ Object
Constructor Details
#initialize ⇒ Server
Returns a new instance of Server.
7 8 9 10 11 12 13 14 15 16 |
# 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 |
Instance Method Details
#clean_old_socket ⇒ Object
18 19 20 21 22 |
# 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) ⇒ Object
24 25 26 27 |
# 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 |