Add factory method to create a Message by from tag and IMessageBuffer#187
Add factory method to create a Message by from tag and IMessageBuffer#187tedbarth wants to merge 2 commits into
Conversation
|
Thanks for the PR! I really like the idea of separating out the serialization from the messages. It will help facilitate using other serializers a lot and will make some usecases a lot simpler without needing writers! I'm not totally convinced exposing an interface for an Secondly I think we need a corresponding read method to get the data out the other end again and that can definitely not be as an IMessageBuffer (for many reasons)! I think there's still value in the prinicple here though. So I wonder if creating |
…allowing to create one from byte[] directly
|
Thanks for the fast reaction! I currently can't see, why |
|
Offtopic: I often get confused by method semantic and now understood why: Your Get Methods often create new objects with separate state. For instance |
|
Oh damn, I somehow closed this issue. :D |
Currently the only way to get pre-serialized Data (
byte[]) into a Message is by either usingDarkRift.DarkRiftWriter.WriteRawand passing the Writer to Message factory method or by passing an object implementingIDarkRiftSerializable.Both ways will cause an unnecessary memory copy of the data.
Luckily
IMessageBufferis public, so we could write this:The PR adds a new method to
Messageallowing to not only pass aDarkRiftWriterbut anIMessageBufferdirectly.Passing the one above will allow us to create and send a Message using pre-serialized data and also helps separating Serialization from Networking.