I'm using ScalaPB to compile my Scala case classes for serializing my protobuf messages.
I have a .proto
file with the following messages:
message WrapperMessage {
oneof msg {
Login login = 1;
Register register = 2;
}
}
message Login {
required string email = 1;
required string password = 2;
}
message Register {
required string email = 1;
required string password = 2;
optional string firstName = 3;
optional string lastName = 4;
}
How do I create my WrapperMessage
knowing that I want to put a Login
message inside the msg
?
val login = Login(email = "test@example.com", password = "testpass")
val wrapperMessage = WrapperMessage(???)
val wrapperMessageBytes = wrapperMessage.toByteArray
Let's say now that I am receiving a WrapperMessage
over the wire; how do I deserialize the message using ScalaPB case class methods?