From bc77e8c056532fc5b601cbeb3de15bed56d0edaa Mon Sep 17 00:00:00 2001 From: Karchnu Date: Thu, 23 Jul 2020 19:24:30 +0200 Subject: [PATCH] Sending IPC::JSON, simplification for IPC::Client. --- src/json.cr | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/json.cr b/src/json.cr index b0c9090..aef746e 100644 --- a/src/json.cr +++ b/src/json.cr @@ -29,6 +29,18 @@ class IPC::Context def send(fd : Int32, message : IPC::JSON) send fd, message.type.to_u8, message.to_json end + def send_now(fd : Int32, message : IPC::JSON) + send_now fd, message.type.to_u8, message.to_json + end +end + +class IPC::Client + def send(message : IPC::JSON) + send @server_fd.not_nil!, message.type.to_u8, message.to_json + end + def send_now(message : IPC::JSON) + send_now @server_fd.not_nil!, message.type.to_u8, message.to_json + end end # CAUTION: Only use this method on an Array(IPC::JSON.class)