This repository has been archived on 2024-06-18. You can view files and clone it, but cannot push or open issues/pull-requests.
2020-07-13 14:17:29 +02:00
|
|
|
|
|
|
|
# the server is a client with a different init function
|
|
|
|
# ipc_connection => ipc_server_init
|
|
|
|
class IPC::Server < IPC::Context
|
|
|
|
def initialize(name : String)
|
|
|
|
initialize()
|
|
|
|
r = LibIPC.ipc_server_init(self.pointer, name)
|
|
|
|
if r.error_code != 0
|
|
|
|
m = String.new r.error_message.to_slice
|
|
|
|
raise Exception.new "cannot initialize the server named #{name}: #{m}"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Very important as there are filesystem side-effects.
|
2020-11-07 02:40:05 +01:00
|
|
|
# FIXME: for now, let's forget that.
|
|
|
|
# at_exit { close }
|
2020-07-13 14:17:29 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# TODO: replacing IPC::Service by the IPC::NetworkD class?
|
|
|
|
class IPC::SwitchingService < IPC::Server
|
|
|
|
property switch = IPC::Switch.new
|
|
|
|
|
|
|
|
# automatic removal of the fd in the switching list
|
|
|
|
def remove_fd (fd : Int)
|
|
|
|
super
|
|
|
|
@switch.del fd
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|