-
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
Protobuf Support for .NET Socket #47
base: master
Are you sure you want to change the base?
Conversation
…g all datamember attributes
Luke Gehorsam seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
/// A Protobuf-Net serializable class corresponding to the well-known | ||
/// google.protobuf.BoolValue type. | ||
/// | ||
/// Keep in mind that grpc-gateway will automatically deserialize a vool into a BoolValue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
(DataMemberAttribute) Attribute.GetCustomAttribute(member, typeof(DataMemberAttribute), true); | ||
return !string.IsNullOrEmpty(dataMemberAttribute.Name) ? dataMemberAttribute.Name : member.Name; | ||
var dataMemberAttribute = (DataMemberAttribute) Attribute.GetCustomAttribute(member, typeof(DataMemberAttribute), true); | ||
return dataMemberAttribute.Name; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EOF
This PR adds protobuf support to the .NET socket via annotations from protobuf-net.
It also moves the concrete socket models to
Nakama.Socket.Internal
. These are no longer strictlyinternal
because theNakama.Protobuf
.dll needs access to them.The primary rationale behind using protobuf-net was its annotations feature. This allows us to not need to write glue code between the generated protobuf types and our interfaces.
The plan for Unity support would be to ship our protobuf .dll inside the same asset and simply document that
using Nakama.Protobuf
will pull in the .dll. Otherwise the .dll will not be included in the build output.Note there is some duplication between the protobuf and text adapters w/r/t the socket lifecycle methods:
Connect
Close
Send
andReceiveLoop
. I debated merging them into some shared object but didn't think it was worth it.TODO
Socket.Internal
: https://docs.microsoft.com/en-us/dotnet/standard/assembly/friend