當前位置: 首頁>>代碼示例>>C#>>正文


C# IoBuffer.Flip方法代碼示例

本文整理匯總了C#中Mina.Core.Buffer.IoBuffer.Flip方法的典型用法代碼示例。如果您正苦於以下問題:C# IoBuffer.Flip方法的具體用法?C# IoBuffer.Flip怎麽用?C# IoBuffer.Flip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mina.Core.Buffer.IoBuffer的用法示例。


在下文中一共展示了IoBuffer.Flip方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Send

 public bool Send(IoBuffer output)
 {
     try
     {
         output.Flip();
         var buffer = output.GetRemainingArray();
         Client.Client.Send(buffer);
     }
     catch (Exception) { return false; }
     if (handler != null)
         return handler.Await();
     return true;
 }
開發者ID:zesus19,項目名稱:c5.v1,代碼行數:13,代碼來源:SimpleTcpClient.cs

示例2: ManipulateIoBuffer

        private void ManipulateIoBuffer(IoSession session, IoBuffer buffer)
        {
            if ((buffer.Remaining > 0) && (_removeByteProbability > _rng.Next(1000)))
            {
                if (log.IsInfoEnabled)
                    log.Info(buffer.GetHexDump());

                // where to remove bytes ?
                int pos = _rng.Next(buffer.Remaining);
                // how many byte to remove ?
                int count = _rng.Next(buffer.Remaining - pos) + 1;
                if (count == buffer.Remaining)
                    count = buffer.Remaining - 1;

                IoBuffer newBuff = IoBuffer.Allocate(buffer.Remaining - count);
                for (int i = 0; i < pos; i++)
                    newBuff.Put(buffer.Get());

                buffer.Skip(count); // hole
                while (newBuff.Remaining > 0)
                    newBuff.Put(buffer.Get());
                newBuff.Flip();
                // copy the new buffer in the old one
                buffer.Rewind();
                buffer.Put(newBuff);
                buffer.Flip();

                if (log.IsInfoEnabled)
                {
                    log.Info("Removed " + count + " bytes at position " + pos + ".");
                    log.Info(buffer.GetHexDump());
                }
            }
            if ((buffer.Remaining > 0) && (_changeByteProbability > _rng.Next(1000)))
            {
                if (log.IsInfoEnabled)
                    log.Info(buffer.GetHexDump());

                // how many byte to change ?
                int count = _rng.Next(buffer.Remaining - 1) + 1;

                byte[] values = new byte[count];
                _rng.NextBytes(values);
                for (int i = 0; i < values.Length; i++)
                {
                    int pos = _rng.Next(buffer.Remaining);
                    buffer.Put(pos, values[i]);
                }

                if (log.IsInfoEnabled)
                {
                    log.Info("Modified " + count + " bytes.");
                    log.Info(buffer.GetHexDump());
                }
            }
        }
開發者ID:zhangf911,項目名稱:Mina.NET,代碼行數:56,代碼來源:ErrorGeneratingFilter.cs

示例3: InternalFlush

 private void InternalFlush(INextFilter nextFilter, IoSession session, IoBuffer buf)
 {
     IoBuffer tmp = null;
     lock (buf)
     {
         buf.Flip();
         tmp = buf.Duplicate();
         buf.Clear();
     }
     if (log.IsDebugEnabled)
         log.Debug("Flushing buffer: " + tmp);
     nextFilter.FilterWrite(session, new DefaultWriteRequest(tmp));
 }
開發者ID:zhangf911,項目名稱:Mina.NET,代碼行數:13,代碼來源:BufferedWriteFilter.cs


注:本文中的Mina.Core.Buffer.IoBuffer.Flip方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。