当前位置: 首页>>代码示例>>C#>>正文


C# ByteBuffer.PutInt方法代码示例

本文整理汇总了C#中ByteBuffer.PutInt方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.PutInt方法的具体用法?C# ByteBuffer.PutInt怎么用?C# ByteBuffer.PutInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.PutInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteTo

 public override void WriteTo(ByteBuffer buffer)
 {
     buffer.PutShort(this.VersionId);
     buffer.PutInt(this.CorrelationId);
     ApiUtils.WriteShortString(buffer, this.ClientId);
     buffer.PutInt(this.Topics.Count);
     foreach (var topic in this.Topics)
     {
         ApiUtils.WriteShortString(buffer, topic);
     }
 }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:11,代码来源:TopicMetadataRequest.cs

示例2: Encode

        /// <summary>
        /// Encodes the supplied <see cref="IRecordedData"/> into the supplied <see cref="ByteBuffer"/>.
        /// </summary>
        /// <param name="data">The data to encode.</param>
        /// <param name="buffer">The target <see cref="ByteBuffer"/> to write to.</param>
        /// <returns>The number of bytes written.</returns>
        public int Encode(IRecordedData data, ByteBuffer buffer)
        {
            int initialPosition = buffer.Position;
            buffer.PutInt(data.Cookie);
            int payloadLengthPosition = buffer.Position;
            buffer.PutInt(0); // Placeholder for payload length in bytes.
            buffer.PutInt(data.NormalizingIndexOffset);
            buffer.PutInt(data.NumberOfSignificantValueDigits);
            buffer.PutLong(data.LowestDiscernibleValue);
            buffer.PutLong(data.HighestTrackableValue);
            buffer.PutDouble(data.IntegerToDoubleValueConversionRatio);

            var payloadLength = FillBufferFromCountsArray(buffer, data);
            buffer.PutInt(payloadLengthPosition, payloadLength);

            var bytesWritten = buffer.Position - initialPosition;
            return bytesWritten;
        }
开发者ID:qooroo,项目名称:HdrHistogram.NET,代码行数:24,代码来源:HistogramEncoderV2.cs

示例3: WriteTo

        public override void WriteTo(ByteBuffer buffer)
        {
            buffer.PutInt(this.CorrelationId);

            /* brokers */
            var brokers = this.ExtractBrokers(this.TopicsMetadata).Values;
            buffer.PutInt(brokers.Count);
            foreach (var broker in brokers)
            {
                broker.WriteTo(buffer);
            }

            /* topic metadata */
            buffer.PutInt(this.TopicsMetadata.Count);
            foreach (var topicMeta in this.TopicsMetadata)
            {
                topicMeta.WriteTo(buffer);
            }
        }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:19,代码来源:TopicMetadataResponse.cs

示例4: WriteTo

        public override void WriteTo(ByteBuffer buffer)
        {
            var groupedStatus = this.statusGroupedByTopic.Value;
            buffer.PutInt(this.CorrelationId);
            buffer.PutInt(groupedStatus.Count); // topic count

            foreach (var topicStatus in groupedStatus)
            {
                var topic = topicStatus.Key;
                var errorsAndOffsets = topicStatus.Value;
                ApiUtils.WriteShortString(buffer, topic);
                buffer.PutInt(errorsAndOffsets.Count); // partition count
                foreach (var kvp in errorsAndOffsets)
                {
                    buffer.PutInt(kvp.Key.Partiton);
                    buffer.PutShort(kvp.Value.Error);
                    buffer.PutLong(kvp.Value.Offset);
                }
            }
        }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:20,代码来源:ProducerResponse.cs

示例5: WriteTo

 public void WriteTo(ByteBuffer buffer)
 {
      /* error code */
     buffer.PutShort(this.ErrorCode);
     /* topic */
     ApiUtils.WriteShortString(buffer, this.Topic);
     /* number of partitions */
     buffer.PutInt(this.PartitionsMetadata.Count());
     foreach (var m in this.PartitionsMetadata)
     {
         m.WriteTo(buffer);
     }
 }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:13,代码来源:TopicMetadata.cs

示例6: WriteTo

        public override void WriteTo(ByteBuffer buffer)
        {
            buffer.PutShort(this.VersionId);
            buffer.PutInt(this.CorrelationId);
            ApiUtils.WriteShortString(buffer, this.ClientId);
            buffer.PutInt(this.ReplicaId);

            buffer.PutInt(this.requestInfoGroupedByTopic.Value.Count);
            foreach (var topicAndPartitionInfos in this.requestInfoGroupedByTopic.Value)
            {
                var topic = topicAndPartitionInfos.Key;
                var partitionInfos = topicAndPartitionInfos.Value;
                ApiUtils.WriteShortString(buffer, topic);
                buffer.PutInt(partitionInfos.Count); // partition count
                foreach (var pi in partitionInfos)
                {
                    var partition = pi.Key.Partiton;
                    var partitionInfo = pi.Value;
                    buffer.PutInt(partition);
                    buffer.PutLong(partitionInfo.Time);
                    buffer.PutInt(partitionInfo.MaxNumOffsets);
                }
            }
        }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:24,代码来源:OffsetRequest.cs

示例7: EncodeSharedObject

		static void EncodeSharedObject(RtmpContext context, ISharedObjectMessage so, ByteBuffer output)
		{
			RtmpWriter writer = new RtmpWriter(output);
            //Set legacy collection flag from context
            writer.UseLegacyCollection = context.UseLegacyCollection;
            writer.UseLegacyThrowable = context.UseLegacyThrowable;

			writer.WriteUTF(so.Name);
			// SO version
			writer.WriteInt32(so.Version);
			// Encoding (this always seems to be 2 for persistent shared objects)
			writer.WriteInt32(so.IsPersistent ? 2 : 0);
			// unknown field
			writer.WriteInt32(0);
			
			int mark, len = 0;

			foreach(ISharedObjectEvent sharedObjectEvent in so.Events)
			{
				byte type = SharedObjectTypeMapping.ToByte(sharedObjectEvent.Type);
				switch(sharedObjectEvent.Type) 
				{
                    case SharedObjectEventType.SERVER_CONNECT:
                    case SharedObjectEventType.CLIENT_INITIAL_DATA:
					case SharedObjectEventType.CLIENT_CLEAR_DATA:
						writer.WriteByte(type);
						writer.WriteInt32(0);
						break;
                    case SharedObjectEventType.SERVER_DELETE_ATTRIBUTE:
                    case SharedObjectEventType.CLIENT_DELETE_DATA:
					case SharedObjectEventType.CLIENT_UPDATE_ATTRIBUTE:
						writer.WriteByte(type);
						mark = (int)output.Position;
						output.Skip(4); // we will be back
						writer.WriteUTF(sharedObjectEvent.Key);
						len = (int)output.Position - mark - 4;
						output.PutInt(mark, len);
						break;
					case SharedObjectEventType.SERVER_SET_ATTRIBUTE:
					case SharedObjectEventType.CLIENT_UPDATE_DATA:
						if (sharedObjectEvent.Key == null) 
						{
							// Update multiple attributes in one request
							IDictionary initialData = sharedObjectEvent.Value as IDictionary;
							foreach(DictionaryEntry entry in initialData)
							{
								writer.WriteByte(type);
								mark = (int)output.Position;
								output.Skip(4); // we will be back
								string key = entry.Key as string;
								object value = entry.Value;
								writer.WriteUTF(key);
								writer.WriteData(context.ObjectEncoding, value);
								
								len = (int)output.Position - mark - 4;
								output.PutInt(mark, len);
							}
						} 
						else 
						{
							writer.WriteByte(type);
							mark = (int)output.Position;
							output.Skip(4); // we will be back
							writer.WriteUTF(sharedObjectEvent.Key);
							writer.WriteData(context.ObjectEncoding, sharedObjectEvent.Value);
							//writer.WriteData(sharedObjectEvent.Value);

							len = (int)output.Position - mark - 4;
							output.PutInt(mark, len);
						}
						break;
					case SharedObjectEventType.CLIENT_SEND_MESSAGE:
					case SharedObjectEventType.SERVER_SEND_MESSAGE:
						// Send method name and value
						writer.WriteByte(type);
						mark = (int)output.Position;
						output.Skip(4); // we will be back

						// Serialize name of the handler to call
						writer.WriteData(context.ObjectEncoding, sharedObjectEvent.Key);
						//writer.WriteUTF(sharedObjectEvent.Key);
						// Serialize the arguments
						foreach(object arg in sharedObjectEvent.Value as IList)
						{
							writer.WriteData(context.ObjectEncoding, arg);
						}
						//writer.WriteData(sharedObjectEvent.Value as IList);
						len = (int)output.Position - mark - 4;
						//output.PutInt(mark, len);
						output.PutInt(mark, len);
						break;
					case SharedObjectEventType.CLIENT_STATUS:
						writer.WriteByte(type);
						mark = (int)output.Position;
						output.Skip(4); // we will be back
						writer.WriteUTF(sharedObjectEvent.Key);
						writer.WriteUTF(sharedObjectEvent.Value as string);
						len = (int)output.Position - mark - 4;
						output.PutInt(mark, len);
						break;
//.........这里部分代码省略.........
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:101,代码来源:RtmpProtocolEncoder.cs

示例8: EncodeHeader

		/// <summary>
		/// Encode RTMP header into given ByteBuffer
		/// </summary>
		/// <param name="header">RTMP message header</param>
		/// <param name="lastHeader">Previous header</param>
		/// <param name="buffer">Buffer to write encoded header to</param>
		/// <returns>Encoded header data</returns>
		public static ByteBuffer EncodeHeader(RtmpHeader header, RtmpHeader lastHeader, ByteBuffer buffer)
		{
			HeaderType headerType = GetHeaderType(header, lastHeader);
			EncodeHeaderByte(buffer, (byte)headerType, header.ChannelId);
			switch(headerType) 
			{
				case HeaderType.HeaderNew:
                    if (header.Timer < 0xffffff)
                        buffer.WriteMediumInt(header.Timer);
                    else
                        buffer.WriteMediumInt(0xffffff);
					buffer.WriteMediumInt(header.Size);
					buffer.Put((byte)header.DataType);
					buffer.WriteReverseInt(header.StreamId);
					break;
				case HeaderType.HeaderSameSource:
                    if (header.Timer < 0xffffff)
                        buffer.WriteMediumInt(header.Timer);
                    else
                        buffer.WriteMediumInt(0xffffff);
                    buffer.WriteMediumInt(header.Size);
					buffer.Put((byte)header.DataType);
					break;
				case HeaderType.HeaderTimerChange:
                    if (header.Timer < 0xffffff)
                        buffer.WriteMediumInt(header.Timer);
                    else
                        buffer.WriteMediumInt(0xffffff);
                    break;
				case HeaderType.HeaderContinue:
					break;
			}

            if (header.Timer >= 0xffffff)
                buffer.PutInt(header.Timer);

			return buffer;
		}
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:45,代码来源:RtmpProtocolEncoder.cs

示例9: MatFileWriter

        /// <summary>
        /// Writes MLArrays into <c>OutputStream</c>
        /// </summary>
        /// <remarks>
        /// Writes MAT-file header and compressed data (<c>miCompressed</c>).
        /// </remarks>
        /// <param name="stream"><c>Stream</c></param>
        /// <param name="data"><c>Collection</c> of <c>MLArray</c> elements.</param>
        /// <param name="compress">Use data compression?</param>
        public MatFileWriter( BinaryWriter stream, ICollection data, bool compress )
        {
            // Write header
            WriteHeader( stream );

            foreach( MLArray matrix in data )
            {
                if (compress)
                {
                    // Prepare buffer for MATRIX data
                    MemoryStream memstrm = new MemoryStream();
                    BinaryWriter bw = new BinaryWriter(memstrm);
                    // Write MATRIX bytes into buffer
                    WriteMatrix(bw, matrix);

                    // Compress data to save storage
                    memstrm.Position = 0; // Rewind the stream

                    MemoryStream compressed = new MemoryStream();
                    zlib.ZOutputStream zos = new zlib.ZOutputStream(compressed, zlib.zlibConst.Z_DEFAULT_COMPRESSION);

                    byte[] input = new byte[128];
                    int len = 0;
                    while ((len = memstrm.Read(input, 0, input.Length)) > 0)
                        zos.Write(input, 0, len);
                    zos.Flush();
                    zos.Close();  // important to note that the zlib.ZOutputStream needs to close before writting out the data to the Base.stream

                    //write COMPRESSED tag and compressed data into output channel
                    byte[] compressedBytes = compressed.ToArray();
                    ByteBuffer buf = new ByteBuffer(2 * 4 + compressedBytes.Length);
                    buf.PutInt(MatDataTypes.miCOMPRESSED);
                    buf.PutInt(compressedBytes.Length);
                    buf.Put(compressedBytes, 0, compressedBytes.Length);

                    stream.Write(buf.Array());

                    compressed.Close();
                }
                else
                {
                    // Write MATRIX bytes into buffer
                    WriteMatrix(stream, matrix);
                }

            }

            stream.Close();
        }
开发者ID:patrickmaster,项目名称:electre-tri,代码行数:58,代码来源:MatFileWriter.cs

示例10: WriteTo

        public void WriteTo(ByteBuffer buffer)
        {
            buffer.PutShort(this.ErrorCode);
            buffer.PutInt(this.PartitionId);

            // leader
            var leaderId = (this.Leader != null) ? this.Leader.Id : TopicMetadata.NoLeaderNodeId;
            buffer.PutInt(leaderId);

            /* number of replicas */
            buffer.PutInt(this.Replicas.Count());
            foreach (var replica in this.Replicas)
            {
                buffer.PutInt(replica.Id);
            }

            /* number of in-sync replicas */
            buffer.PutInt(this.Isr.Count());
            foreach (var r in this.Isr)
            {
                buffer.PutInt(r.Id);
            }
        }
开发者ID:Cnova,项目名称:kafka-net,代码行数:23,代码来源:TopicMetadata.cs

示例11: WriteTo

 public override void WriteTo(ByteBuffer buffer)
 {
     buffer.PutShort(this.VersionId);
     buffer.PutInt(this.CorrelationId);
     ApiUtils.WriteShortString(buffer, this.ClientId);
     buffer.PutInt(this.ReplicaId);
     buffer.PutInt(this.MaxWait);
     buffer.PutInt(this.MinBytes);
     buffer.PutInt(this.requestInfoGroupedByTopic.Value.Count); // topic count
     foreach (var kvp in this.requestInfoGroupedByTopic.Value)
     {
         var topic = kvp.Key;
         var partitionFetchInfos = kvp.Value;
         ApiUtils.WriteShortString(buffer, topic);
         buffer.PutInt(partitionFetchInfos.Count); // partition count
         foreach (var pfi in partitionFetchInfos)
         {
             buffer.PutInt(pfi.Key.Partiton);
             buffer.PutLong(pfi.Value.Offset);
             buffer.PutInt(pfi.Value.FetchSize);
         }
     }
 }
开发者ID:ajperrins,项目名称:kafka-net,代码行数:23,代码来源:FetchRequest.cs

示例12: CopyRawTo

 /// <summary>Copy this ObjectId to an output writer in raw binary.</summary>
 /// <remarks>Copy this ObjectId to an output writer in raw binary.</remarks>
 /// <param name="w">the buffer to copy to. Must be in big endian order.</param>
 public virtual void CopyRawTo(ByteBuffer w)
 {
     w.PutInt(w1);
     w.PutInt(w2);
     w.PutInt(w3);
     w.PutInt(w4);
     w.PutInt(w5);
 }
开发者ID:sharwell,项目名称:ngit,代码行数:11,代码来源:AnyObjectId.cs

示例13: WriteTo

        public override void WriteTo(ByteBuffer buffer)
        {
            buffer.PutShort(this.VersionId);
            buffer.PutInt(this.CorrelationId);
            ApiUtils.WriteShortString(buffer, this.ClientId);
            buffer.PutShort(this.RequiredAcks);
            buffer.PutInt(this.AckTimeoutMs);

            // save the topic structure
            buffer.PutInt(this.dataGroupedByTopic.Value.Count); // the number of topics
            foreach (var kvp in this.dataGroupedByTopic.Value)
            {
                var topic = kvp.Key;
                var topicAndPartitonData = kvp.Value;
                ApiUtils.WriteShortString(buffer, topic); // write the topic
                buffer.PutInt(topicAndPartitonData.Count);
                foreach (var partitionAndData in topicAndPartitonData)
                {
                    var partition = partitionAndData.Key.Partiton;
                    var partitionMessageData = partitionAndData.Value;
                    var bytes = partitionMessageData.Buffer;
                    buffer.PutInt(partition);
                    buffer.PutInt((int)bytes.Length);
                    buffer.Put(bytes);
                    bytes.Position = 0;
                }
            }
        }
开发者ID:Cnova,项目名称:kafka-net,代码行数:28,代码来源:ProducerRequest.cs

示例14: MD5_QQ_2_Encrypt

 /// <summary>
 /// 新版本动态密码获取方法
 /// </summary>
 /// <param name="uin"></param>
 /// <param name="password"></param>
 /// <param name="verifyCode"></param>
 /// <returns></returns>
 public static string MD5_QQ_2_Encrypt(long uin, string password, string verifyCode)
 {
     ByteBuffer buffer= new ByteBuffer();
     buffer.Put(MD5_GetBytes(password));
     buffer.PutInt(0);
     buffer.PutInt((uint)uin);
     byte[] bytes = buffer.ToByteArray();
     string md5_1 = MD5_Encrypt(bytes);//将混合后的字节流进行一次md5加密
     string result= MD5_Encrypt(md5_1 + verifyCode.ToUpper());//再用加密后的结果与大写的验证码一起加密一次
     return result;
 }
开发者ID:FormatD,项目名称:qqrobot,代码行数:18,代码来源:MD5Helper.cs

示例15: EncodeIntoCompressedByteBuffer

        /// <summary>
        /// Encode this histogram in compressed form into a <see cref="ByteBuffer"/>.
        /// </summary>
        /// <param name="source">The histogram to encode</param>
        /// <param name="targetBuffer">The buffer to write to</param>
        /// <returns>The number of bytes written to the buffer</returns>
        public static int EncodeIntoCompressedByteBuffer(this HistogramBase source, ByteBuffer targetBuffer)
        {
            int neededCapacity = source.GetNeededByteBufferCapacity();
            var intermediateUncompressedByteBuffer = ByteBuffer.Allocate(neededCapacity);
            source.Encode(intermediateUncompressedByteBuffer, HistogramEncoderV2.Instance);

            int initialTargetPosition = targetBuffer.Position;
            targetBuffer.PutInt(GetCompressedEncodingCookie());
            int compressedContentsHeaderPosition = targetBuffer.Position;
            targetBuffer.PutInt(0); // Placeholder for compressed contents length
            var compressedDataLength = targetBuffer.CompressedCopy(intermediateUncompressedByteBuffer, targetBuffer.Position);

            targetBuffer.PutInt(compressedContentsHeaderPosition, compressedDataLength); // Record the compressed length
            int bytesWritten = compressedDataLength + 8;
            targetBuffer.Position = (initialTargetPosition + bytesWritten);
            return bytesWritten;
        }
开发者ID:HdrHistogram,项目名称:HdrHistogram.NET,代码行数:23,代码来源:HistogramEncoding.cs


注:本文中的ByteBuffer.PutInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。