Compare commits

...

5 Commits

Author SHA1 Message Date
Karchnu 7d4d59a073 Client can send messages. 2020-07-14 17:46:45 +02:00
Karchnu 3c7a43cb54 typo 2020-07-14 15:45:39 +02:00
Karchnu 867484aab4 Test 2020-07-14 14:17:06 +02:00
Karchnu 1326bcf8e5 Client can send request without indicating a server 2020-07-14 14:13:46 +02:00
Karchnu a5c6ebbc89 client sending a message: by default with a the server fd 2020-07-14 13:44:49 +02:00
1 changed files with 17 additions and 13 deletions

View File

@ -169,12 +169,6 @@ class AuthD::Response
end
end
class IPC::Context
def send(fd, response : AuthD::Response)
send fd, response.type.to_u8, response.to_json
end
end
class AuthD::Request
include JSON::Serializable
@ -369,12 +363,6 @@ class AuthD::Request
end
end
class IPC::Context
def send(fd, request : AuthD::Request)
send fd, request.type.to_u8, request.to_json
end
end
module AuthD
class Client < IPC::Client
property key : String
@ -422,7 +410,7 @@ module AuthD
end
def send(type : Request::Type, payload)
send type.value.to_u8, payload
send @server_fd, type.value.to_u8, payload
end
def decode_token(token)
@ -586,3 +574,19 @@ module AuthD
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)
unless (fd = @server_fd).nil?
send fd, request.type.to_u8, request.to_json
else
raise "Client not connected to the server"
end
end
end