mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-12-26 21:58:10 +01:00
Port Lua client fix
This commit is contained in:
parent
556294d4ef
commit
67ee5021bd
1 changed files with 36 additions and 20 deletions
|
@ -136,9 +136,14 @@ function client.server_streaming_request(grpc_request_params, callback)
|
|||
|
||||
client.loop:wrap(function()
|
||||
for response_body in stream:each_chunk() do
|
||||
-- Skip the 1-byte compressed flag and the 4-byte message length
|
||||
---@diagnostic disable-next-line: redefined-local
|
||||
local response_body = response_body:sub(6)
|
||||
local response_body = response_body
|
||||
|
||||
while response_body:len() > 0 do
|
||||
local msg_len = string.unpack(">I4", response_body:sub(2, 5))
|
||||
|
||||
-- Skip the 1-byte compressed flag and the 4-byte message length
|
||||
response_body = response_body:sub(6, 6 + msg_len - 1)
|
||||
|
||||
---@diagnostic disable-next-line: redefined-local
|
||||
local success, obj = pcall(pb.decode, response_type, response_body)
|
||||
|
@ -149,6 +154,9 @@ function client.server_streaming_request(grpc_request_params, callback)
|
|||
|
||||
local response = obj
|
||||
callback(response)
|
||||
|
||||
response_body = response_body:sub(msg_len + 1)
|
||||
end
|
||||
end
|
||||
|
||||
local trailers = stream:get_headers()
|
||||
|
@ -184,9 +192,14 @@ function client.bidirectional_streaming_request(grpc_request_params, callback)
|
|||
|
||||
client.loop:wrap(function()
|
||||
for response_body in stream:each_chunk() do
|
||||
-- Skip the 1-byte compressed flag and the 4-byte message length
|
||||
---@diagnostic disable-next-line: redefined-local
|
||||
local response_body = response_body:sub(6)
|
||||
local response_body = response_body
|
||||
|
||||
while response_body:len() > 0 do
|
||||
local msg_len = string.unpack(">I4", response_body:sub(2, 5))
|
||||
|
||||
-- Skip the 1-byte compressed flag and the 4-byte message length
|
||||
response_body = response_body:sub(6, 6 + msg_len - 1)
|
||||
|
||||
---@diagnostic disable-next-line: redefined-local
|
||||
local success, obj = pcall(pb.decode, response_type, response_body)
|
||||
|
@ -197,6 +210,9 @@ function client.bidirectional_streaming_request(grpc_request_params, callback)
|
|||
|
||||
local response = obj
|
||||
callback(response)
|
||||
|
||||
response_body = response_body:sub(msg_len + 1)
|
||||
end
|
||||
end
|
||||
|
||||
local trailers = stream:get_headers()
|
||||
|
|
Loading…
Reference in a new issue