-
Notifications
You must be signed in to change notification settings - Fork 48
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
How to use protobuf protocol? #16
Comments
All you should do is that using protobuf protocol serializer before you call starx.SetSerializer(protobuf.NewProtobufSerializer()) In addition, the second parameter of your handler method should be a struct that could be serialized/deserialized by protobuf. func (f *Foo)Bar(s *session.Session, m *proto.SomeProtobufStruct) error {
//you game logic
s.Response(&proto.AnotherProtobufStruct{})
} That all. |
Thanks for answer! |
i try to change your chat example Server Client Error: |
You can't combine JSON and Protobuf in the current version of StarX, but could combine for different server type. starx.Set("server-type", func(){
starx.SetSerializer(json.NewJsonSerializer())
})
starx.Set("server-type-2", func() {
starx.SetSerializer(protobuf.NewProtobufSerializer())
}) |
Okay thanks, but what i doing wrong in message upper? |
Seems like you struct with wrong tags Try this: type Message struct {
Data string `protobuf:"bytes,1,name=data"`
} |
How to use protobuf protocol?
The text was updated successfully, but these errors were encountered: