From 6b50f08c86fc31a2e2e4e865c36e69e7a1e91b74 Mon Sep 17 00:00:00 2001 From: imi415 Date: Sun, 31 Jul 2022 16:35:02 +0800 Subject: [PATCH] Fixed request type identification. --- src/client.rb | 8 +++++--- src/server.rb | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/client.rb b/src/client.rb index cbcf8a4..0531038 100644 --- a/src/client.rb +++ b/src/client.rb @@ -25,10 +25,12 @@ begin client.subscribe('iot/weather/testclient/response') client.publish('iot/weather/testclient/request', { type: 'condition', city_id: 10 }.to_cbor) + client.publish('iot/weather/testclient/request', { type: 'aqi', city_id: 10 }.to_cbor) + client.publish('iot/weather/testclient/request', { type: 'forecast24', city_id: 10 }.to_cbor) - _, payload = client.get - p CBOR.decode(payload) - + client.get do |_, payload| + p CBOR.decode(payload) + end rescue SystemExit, Interrupt puts "Interrupt caught, client [#{client}] disconnect." client.disconnect diff --git a/src/server.rb b/src/server.rb index 5209ddb..e827858 100644 --- a/src/server.rb +++ b/src/server.rb @@ -73,6 +73,8 @@ begin next end + req_params[:type] = wx_cond + # Check cache api_resp = cache["cache_#{req_params}"]