From 867484aab421ca28440aa7811aed5b1c9bb86588 Mon Sep 17 00:00:00 2001 From: Karchnu Date: Tue, 14 Jul 2020 14:17:06 +0200 Subject: [PATCH] Test --- src/authd.cr | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/authd.cr b/src/authd.cr index 7d5b582..12c5817 100644 --- a/src/authd.cr +++ b/src/authd.cr @@ -363,18 +363,6 @@ class AuthD::Request end end -class IPC::Context - def send(fd, response : AuthD::Response) - send fd, response.type.to_u8, response.to_json - end -end - -class IPC::Client - def send(request : AuthD::Request) - send @server_fd, request.type.to_u8, request.to_json - end -end - module AuthD class Client < IPC::Client property key : String @@ -574,3 +562,27 @@ module AuthD send Request::SearchUser.new user_login response = Response.from_ipc read + case response + when Response::MatchingUsers + response.users + when Response::Error + raise Exception.new response.reason + else + Exception.new + end + end + end +end + +class IPC::Context + def send(fd, response : AuthD::Response) + send fd, response.type.to_u8, response.to_json + end +end + +class IPC::Client + def send(request : AuthD::Request) + send @server_fd, }equest.type.to_u8, request.to_json + end +end +