public Ss1a(byte[] bytes) : this() { var ver = VgcApis.Libs.Streams.BitStream.ReadVersion(bytes); if (ver != version) { throw new NotSupportedException( $"Not supported version ${ver}"); } using (var bs = new VgcApis.Libs.Streams.BitStream(bytes)) { var readString = Utils.GenReadStringHelper(bs, strTable); alias = bs.Read <string>(); description = readString(); address = bs.ReadAddress(); port = bs.Read <int>(); password = bs.Read <string>(); method = readString(); networkType = bs.ReadTinyInt(networkTypeLenInBits); isUseOta = bs.Read <bool>(); isUseTls = bs.Read <bool>(); streamType = readString(); streamParam1 = readString(); streamParam2 = readString(); streamParam3 = readString(); } }
public static string ReadString( VgcApis.Libs.Streams.BitStream bitStream, List <string> strTable) { var lenInBits = VgcApis.Misc.Utils.GetLenInBitsOfInt(strTable.Count); if (bitStream.Read <bool>()) { // using string table var index = bitStream.ReadTinyInt(lenInBits); return(strTable[index]); } else { return(bitStream.Read <string>()); } }
public void ShortIntTest() { var rand = new Random(); for (int i = 0; i < 10; i++) { bs.Clear(); const int len = 7; var source = new List <int>(); for (int j = 0; j < 3; j++) { var val = rand.Next(127); source.Add(val); bs.WriteTinyInt(val, len); } for (int j = 0; j < 3; j++) { var read = bs.ReadTinyInt(len); Assert.AreEqual(source[j], read); } } }