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

proto协议返回map类型值 #50

Open
flyy3 opened this issue Apr 6, 2016 · 5 comments
Open

proto协议返回map类型值 #50

flyy3 opened this issue Apr 6, 2016 · 5 comments

Comments

@flyy3
Copy link

flyy3 commented Apr 6, 2016

返回

map={  
[32000001] = 10,
[32000002] = 5},

key不固定,proto.lua的返回值类型该怎么写?

@cloudwu
Copy link
Owner

cloudwu commented Apr 6, 2016

你需要定义一个类型,并声明 main index 。

.foo {
    key 0 : integer
    value 1 : integer
}

.map {
    map 0 : *foo(key)
}

@lindxsea
Copy link

lindxsea commented Jan 5, 2017

window下,cocos2d如何用lua调用proto协议,需要skynet下的哪些文件,才能运行

@cloudwu
Copy link
Owner

cloudwu commented Jan 11, 2017

sproto 和 skynet 无关。

@cuixin
Copy link

cuixin commented Jul 13, 2018

@cloudwu ,protobuf 3.x是支持map的,sproto有计划支持map类型吗?

@tqing1128
Copy link

@cuixin
wiki:

You can also specify a main index with the syntax likes *array(id), the array would be encode as an unordered map with the id field as key.

For empty main index likes *array(), the array would be encoded as an unordered map with the first field as key and the second field as value.

像下面这样使用就是 map

.foo {
    key 0 : integer
    value 1 : integer
}

.map {
    map 0 : *foo()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants