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

oneof field with messages in it not generating set method #9

Closed
Quak0r opened this issue Dec 5, 2020 · 2 comments
Closed

oneof field with messages in it not generating set method #9

Quak0r opened this issue Dec 5, 2020 · 2 comments

Comments

@Quak0r
Copy link

Quak0r commented Dec 5, 2020

Hello,
first of a BIG thank you for all the work that went into this project!

I'm trying to have a message wrapper so I can send only one message over the wire in order to have easier message recognition on the receiving end.

syntax = "proto3";

enum PlayerCommand {
    SHOOT = 0;
}
message PlayerPosition {
    int32 id = 1;
    float x = 2;
    float y = 3;
    float rot = 4;
}

message PlayerInput {
    int32 id = 1;
    float rotL = 2;
    float rotM = 3;
    repeated PlayerCommand com = 4;
}

message PlayerPositions {
    repeated PlayerPosition playerpos = 1;
}

message CompositeMessage {
    oneof payload {
        PlayerPosition playerstart = 1;
        PlayerInput playerupdate = 2;
        int32 removeplayer = 3;
        PlayerPositions allplayersupdate = 4;
    }
  }

the generated code however does not seem to have the setter functions for playerstart, playerupdate and allplayersupdate. The only setter generated is set_removeplayer. The other type of functions like get_playerupdate , clear_playerupdate and new_playerupdate are generated correctly.

@oniksan
Copy link
Owner

oniksan commented Dec 7, 2020

Hello, Quak0r.
Your CompositeMessage contains one of three Objects (messages) or one simple type (int32). All simple types are set by setters:

var compositeMessage = MyProto.CompositeMessage.new()
compositeMessage.set_removeplayer(42)

But All Messages are set by creating new Messages (see manual):

var compositeMessage = MyProto.CompositeMessage.new()
var player = compositeMessage.new_playerupdate()
player.set_id(10)
player.rotL(15.)
...

It seems something like this :)

@Quak0r
Copy link
Author

Quak0r commented Dec 7, 2020

Ah! I must have missed that in the manual.
Just tested it quickly and it adds the different messages to the CompositeMessage wrapper correctly!

Thank you!

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

2 participants