【问题标题】:Thrift Example in LuaLua 中的 Thrift 示例
【发布时间】:2015-08-10 19:06:34
【问题描述】:

在哪里可以找到如何在 lua 中加载 Thrift 文件的示例?

到目前为止,我的代码如下。我不知道如何创建内存缓冲区。它在 TMemoryBuffer:new() 失败

local fullpath = FullPath("ConfigData.bin")
local infile = io.open(fullpath, "rb")
local buffer = infile:read("*all")

local transport1 = TMemoryBuffer:new()
transport1:resetBuffer(buffer)
local transport = TFramedTransportFactory:getTransport(transport1) local protocol = TBinaryProtocolFactory:getProtocol(transport)
flux.assert(protocol)
Data:read(protocol)

【问题讨论】:

标签: lua thrift


【解决方案1】:

这是一个工作示例:

local fullpath = FullPath("ConfigData.bin")
local infile = io.open(fullpath, "rb")
local buffer = infile:read("*all")

TMemoryBuffer:resetBuffer(buffer)
local protocol = TBinaryProtocolFactory:getProtocol(TMemoryBuffer)
Data:read(protocol)

【讨论】:

    猜你喜欢
    • 2012-10-31
    • 1970-01-01
    • 2014-12-28
    • 2012-03-12
    • 1970-01-01
    • 2012-04-14
    • 2017-04-15
    • 2022-07-07
    • 1970-01-01
    相关资源
    最近更新 更多