Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Hue/Sonos) Use new Luncheon features if available #1152

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions drivers/SmartThings/philips-hue/src/lunchbox/rest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ local lb_utils = require "lunchbox.util"
local Request = require "luncheon.request"
local Response = require "luncheon.response"

local api_version = require("version").api

local RestCallStates = {
SEND = "Send",
RECEIVE = "Receive",
Expand Down Expand Up @@ -129,6 +131,11 @@ local function parse_chunked_response(original_response, sock)
end

local function handle_response(sock)
if api_version >= 9 then
local response, err = Response.tcp_source(sock)
if err or (not response) then return response, (err or "unknown error") end
return response, response:fill_body()
end
-- called select right before passing in so we receive immediately
local initial_recv, initial_err, partial = Response.source(function() return sock:receive('*l') end)

Expand Down
7 changes: 7 additions & 0 deletions drivers/SmartThings/sonos/src/lunchbox/rest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ local utils = require "utils"
local Request = require "luncheon.request"
local Response = require "luncheon.response"

local api_version = require("version").api

local RestCallStates = {
SEND = "Send",
RECEIVE = "Receive",
Expand Down Expand Up @@ -132,6 +134,11 @@ local function parse_chunked_response(original_response, sock)
end

local function handle_response(sock)
if api_version >= 9 then
local response, err = Response.tcp_source(sock)
if err or (not response) then return response, (err or "unknown error") end
return response, response:fill_body()
end
-- called select right before passing in so we receive immediately
local initial_recv, initial_err, partial = Response.source(function() return sock:receive('*l') end)

Expand Down
Loading