Class: Invoker::IPC::Server
- Inherits:
-
Object
- Object
- Invoker::IPC::Server
- Defined in:
- lib/invoker/ipc/server.rb
Constant Summary collapse
- SOCKET_PATH =
"/tmp/invoker"
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 |
# File 'lib/invoker/ipc/server.rb', line 7 def initialize @open_clients = [] Socket.unix_server_loop(SOCKET_PATH) do |sock, client_addrinfo| Thread.new { process_client(sock) } end end |
Instance Method Details
#clean_old_socket ⇒ Object
14 15 16 17 18 |
# File 'lib/invoker/ipc/server.rb', line 14 def clean_old_socket if File.exist?(SOCKET_PATH) FileUtils.rm(SOCKET_PATH, :force => true) end end |
#process_client(client_socket) ⇒ Object
20 21 22 23 |
# File 'lib/invoker/ipc/server.rb', line 20 def process_client(client_socket) client = Invoker::IPC::ClientHandler.new(client_socket) client.read_and_execute end |