This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues/pull-requests.
2019-07-27 15:29:27 +02:00
|
|
|
require "./lowlevel"
|
|
|
|
require "./message"
|
|
|
|
require "./event"
|
|
|
|
require "./service"
|
|
|
|
require "./connection"
|
|
|
|
|
|
|
|
|
|
|
|
class IPC::Client < IPC::Connections
|
|
|
|
@connection : IPC::Connection
|
|
|
|
|
|
|
|
def initialize(name : String)
|
|
|
|
super()
|
|
|
|
@connection = IPC::Connection.new name
|
|
|
|
self << @connection
|
|
|
|
end
|
|
|
|
|
2020-01-01 14:29:05 +01:00
|
|
|
def initialize(name : String, &block : Proc(IPC::Event::Events|Exception, Nil))
|
2019-07-27 15:29:27 +02:00
|
|
|
initialize name
|
|
|
|
::loop &block
|
|
|
|
close
|
|
|
|
end
|
|
|
|
|
|
|
|
def send(*args)
|
|
|
|
@connection.send *args
|
|
|
|
end
|
|
|
|
|
|
|
|
def read(*args)
|
|
|
|
@connection.read *args
|
|
|
|
end
|
|
|
|
|
|
|
|
# sanitizer
|
|
|
|
def fd
|
|
|
|
@connection.fd
|
|
|
|
end
|
|
|
|
|
2020-01-01 14:29:05 +01:00
|
|
|
def loop(&block : Proc(IPC::Event::Events|Exception, Nil))
|
2019-07-27 15:29:27 +02:00
|
|
|
super(nil, &block)
|
|
|
|
end
|
|
|
|
|
|
|
|
def close
|
|
|
|
@connection.close
|
|
|
|
end
|
|
|
|
end
|