protobuf-net

How to properly handle incoming protobuf message with a NetworkStream?

∥☆過路亽.° 提交于 2019-12-11 04:24:17
问题 Using TCPClient's NetworkStream and protobuf-net I send and receive protobuf messages via TCP. Receiving is done with the following method that runs in an own thread: private void HandleClientComm() { using (NetworkStream stream = m_Stream) { object o; while (true) { if (stream.CanRead && stream.DataAvailable) { o = null; if (Serializer.NonGeneric.TryDeserializeWithLengthPrefix(stream, PrefixStyle.Base128, Utilities.CommunicationHelper.resolver, out o)) { if (o != null) { //Do something with

NHibernate MemCached w/ Protobuf-net.Enyim — does it actually work?

谁说我不能喝 提交于 2019-12-11 04:09:11
问题 I've used the following assemblies to hook up NHibernate 2nd-level caching with Enyim Memcached using Protobuf-net binary serializer: NHibernate NHibernate.Caches.EnyimMemcached Enyim.Caching protobuf-net protobuf-net.Enyim It's recently come to my attention that despite hooking up protobuf-net with EnyimMemcached, I'm likely not actually using that serializer as all my entities were marked with just [Serializable] and neither [DataContract] or [ProtoContract] with corresponding ordered Data

Using Protobuf-net, I get an exception about an unknown wire-type with List<Subclassable>

烈酒焚心 提交于 2019-12-11 03:57:41
问题 I've started to convert our Unity/iOS game to save state with Protobuf-net. It looked like things were working OK, until I added this instance variable to GameState [ProtoMember(10)] public List<Unit> fUnits; Unit is [ProtoContract] [ProtoInclude(21, typeof(ArtilleryUnit))] [ProtoInclude(22, typeof(CavalryArtilleryUnit))] [ProtoInclude(23, typeof(CavalryUnit))] [ProtoInclude(24, typeof(InfantryUnit))] [Serializable] public class Unit : IActionHandler This is the first subclass I've serialized

protobuf: consecutive serialize and deserialize to/from socket

此生再无相见时 提交于 2019-12-11 03:52:15
问题 My simple communication between C++ client and C# server got stuck after a message was serialized to socket (SerializeToFileDescritor). C++ client: Person person; person.set_id(54321); person.set_name("bla"); person.mutable_address()->set_line1("sdfa"); person.mutable_address()->set_line2("asdfsdfa"); cout << person.id() << endl << person.name() << endl; cout << person.address().line2() << endl; person.SerializeToFileDescriptor(s); ZeroCopyInputStream* raw_input = new FileInputStream(s);

Recovering corrupted file serialize with Protobuf-net

帅比萌擦擦* 提交于 2019-12-11 03:32:49
问题 The machine power was cut while, I assume, my application was updating a file. When turned back on and my application started it attempted to deserialize the file. The call to Serializer.Deserialize did not fail, but the resulting object has default values for every property. My file updating/saving: using (FileStream theStream = File.Open(fileName + "_tmp", FileMode.Create)) { ProtoBuf.Serializer.Serialize<MyObject>(theStream, inObjectToSerialize); } File.Copy(fileName + "_tmp", fileName,

Can't serialize generic type

大憨熊 提交于 2019-12-11 02:48:12
问题 I'm trying to serialize a generic type with protobuf-net, but protobuf-net says it can't serialize it. As in: RuntimeTypeModel.Default.CanSerialize(typeof(MyGenericClass<>)) returns true and RuntimeTypeModel.Default.CanSerialize(typeof(string)) returns true, too. But RuntimeTypeModel.Default.CanSerialize(typeof(MyGenericClass<string>)) //--> applies to all types that would return true when directly serialized as shown above for the string type returns false. I guess I'm doing something wrong

Protobuf with Multidimensional Array

蹲街弑〆低调 提交于 2019-12-11 02:41:16
问题 I'm working on saving and loading for a game being developed in c# xna. I have a long list of class arrays that I'm trying to serialize and im coming across a problem with one of them. Ive done the class like the following [ProtoContract] public class CompleteTile { int _id; [ProtoMember(1)] public int ID { get { return _id; } set { _id = value; } } bool _Passable; [ProtoMember(2)] public bool Passable { get { return _Passable; } set { _Passable = value; } } I can successfully serialize it

serialize list of huge composite graphs using protobuf-net causing out-of-memory-exception

时光总嘲笑我的痴心妄想 提交于 2019-12-11 02:22:28
问题 I am trying to serialize an object containing a list of very large composite object graphs (~200000 nodes or more) using Protobuf-net. Basically what I want to achieve is to save the complete object into a single file as fast and as compact as possible. My problem is that I get an out-of-memory-exception while trying to serialize the object. On my machine the exception is thrown when the file size is around 1.5GB. I am running a 64 bit process and using a StreamWriter as input to protobuf-net

ProtoBuf serialization missing data even for simple entities

烂漫一生 提交于 2019-12-11 00:35:28
问题 [Update#1] : I've uploaded my modified and fixed "demo" project to https://github.com/sidshetye/SerializersCompare should anyone else be interested in checking out the benchmark. [Update#2] :I'm seeing that ProtoBufs takes the order of magnitude lead only on subsequent iterations. For a one-time serialization, BinaryFormatter is the one which is an order of magnitude faster. Why? Separate question ... I'm trying to compare BinaryFormatter, Json.NET and ProtoBuf.NET (got the latter off NuGet

protobuf-net missing has_ function for optional fields?.

核能气质少年 提交于 2019-12-11 00:24:37
问题 We use protocol buffers for communication between native C++ apps, but also between native C++ app and .NET application (all is VS2012) via protobuf-net r666. We rely in C++ heavily on the has_ functions that are available for an optional element. E.g. if we have a message with a field optional bool, it can be that it is not set, it is set to true, or it is set to false. In C++ this can be checked with the function has_field and if set then the content can be fetched with get_field function.