public static RawBrowserMessageEnvelop Deserialize(BinaryReader r)
        {
            var version = r.ReadInt32();

            if (version == 1)
            {
                return(RawBrowserMessageEnvelopSerializerV1.Deserialize(r));
            }
            if (version == Int32.MaxValue) //custom data
            {
                var data = StreamHelper.ReadString(r);
                return(new RawBrowserMessageEnvelop {
                    MessageType = "custom", CustomData = data
                });
            }
            throw new InvalidDataException($"Version ${version} not supported.");
        }
 public void Serialize(BinaryWriter w)
 {
     RawBrowserMessageEnvelopSerializerV1.Serialize(this, w);
 }