From 57ce9d2e384de3827592a7a70f403afd18d55190 Mon Sep 17 00:00:00 2001 From: Karchnu Date: Fri, 3 Jul 2020 16:14:46 +0200 Subject: [PATCH] compiles --- src/ipc/context.cr | 19 ++++++++++--------- src/ipc/service.cr | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/ipc/context.cr b/src/ipc/context.cr index 0cc4577..062de57 100644 --- a/src/ipc/context.cr +++ b/src/ipc/context.cr @@ -4,8 +4,8 @@ require "./event" require "./connection" class IPC::Context - property base_timer : Float64 = 0.0 - property timer : Float64 = 0.0 + property base_timer : UInt32 = 0 + property timer : UInt32 = 0 getter context : LibIPC::Ctx def initialize @@ -69,7 +69,7 @@ class IPC::Context when LibIPC::EventType::NotSet return Exception.new "'Event type: not set" when LibIPC::EventType::Error - return IPC::Event::Error.new event.index, event.origin + return IPC::Event::Error.new event.origin, event.index when LibIPC::EventType::ExtraSocket # Message received from a non IPC socket. return IPC::Event::ExtraSocket.new event.origin, event.index when LibIPC::EventType::Switch # Message to send to a corresponding fd. @@ -79,8 +79,9 @@ class IPC::Context when LibIPC::EventType::Disconnection # User disconnected. return IPC::Event::Disconnection.new event.origin, event.index when LibIPC::EventType::Message # New message. - message = event.message.unsafe_as(Pointer(LibIPC::Message)) - return IPC::Event::MessageReceived.new event.origin, event.index, message + lowlevel_message = event.message.unsafe_as(Pointer(LibIPC::Message)) + ipc_message = IPC::Message.new lowlevel_message + return IPC::Event::MessageReceived.new event.origin, event.index, ipc_message when LibIPC::EventType::LookUp # Client asking for a service through ipcd. # for now, the libipc does not provide lookup events # ipcd uses a simple LibIPC::EventType::Message @@ -88,10 +89,10 @@ class IPC::Context when LibIPC::EventType::Timer # Timeout in the poll(2) function. return IPC::Event::Timer.new when LibIPC::EventType::Tx # Message sent. - return IPC::Event::Tx.new event.origin, event.index + return IPC::Event::MessageSent.new event.origin, event.index end - yield Exception.new "Cannot understand the event type: #{eventtype}" + return Exception.new "Cannot understand the event type: #{eventtype}" end def loop(&block : Proc(IPC::Event::Events|Exception, Nil)) @@ -122,8 +123,8 @@ class IPC::Context send(fd, utype, Bytes.new(payload.to_unsafe, payload.bytesize)) end - def send(fd : Int32, message : IPC::Message) - send(fd, message.utype, message.payload) + def send(message : IPC::Message) + send(message.fd, message.utype, message.payload) end def read(index : UInt32) diff --git a/src/ipc/service.cr b/src/ipc/service.cr index c24bd48..2d2d928 100644 --- a/src/ipc/service.cr +++ b/src/ipc/service.cr @@ -35,9 +35,9 @@ class IPC::Service < IPC::Context @service_info.fd end - def loop(&block : Proc(IPC::Event::Events|Exception, Nil)) - super(@service_info, &block) - end + # def loop(&block : Proc(IPC::Event::Events|Exception, Nil)) + # super(@service_info, &block) + # end def close @service_info.close