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


C# IoSession类代码示例

本文整理汇总了C#中IoSession的典型用法代码示例。如果您正苦于以下问题:C# IoSession类的具体用法?C# IoSession怎么用?C# IoSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Decode

 public void Decode(IoSession session, IoBuffer input, IProtocolDecoderOutput output)
 {
     lock (_decoder)
     {
         _decoder.Decode(session, input, output);
     }
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:7,代码来源:SynchronizedProtocolDecoder.cs

示例2: IsResponse

 public bool IsResponse(IoSession session, object message)
 {
     var isResponse = false;
     var heartbeat = message as DuplexMessage;
     if (heartbeat != null) isResponse = heartbeat.Header.MessageType == MessageType.Heartbeat;
     return isResponse;
 }
开发者ID:zesus19,项目名称:c5.v1,代码行数:7,代码来源:KeepAliveMessageFactory.cs

示例3: FinishDecode

 public void FinishDecode(IoSession session, IProtocolDecoderOutput output)
 {
     lock (_decoder)
     {
         _decoder.FinishDecode(session, output);
     }
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:7,代码来源:SynchronizedProtocolDecoder.cs

示例4: IsRequest

 public bool IsRequest(IoSession session, object message)
 {
     var isRequest = false;
     var heartbeat = message as DuplexMessage;
     if (heartbeat != null) isRequest = heartbeat.Header.CommandCode == CommandCode.Heartbeat;
     return isRequest;
 }
开发者ID:zesus19,项目名称:c5.v1,代码行数:7,代码来源:KeepAliveMessageFactory.cs

示例5: IoFilterEvent

 public IoFilterEvent(INextFilter nextFilter, IoEventType eventType, IoSession session, Object parameter)
     : base(eventType, session, parameter)
 {
     if (nextFilter == null)
         throw new ArgumentNullException("nextFilter");
     _nextFilter = nextFilter;
 }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:7,代码来源:IoFilterEvent.cs

示例6: ExceptionCaught

 /// <inheritdoc/>
 public virtual void ExceptionCaught(IoSession session, Exception cause)
 {
     if (log.IsWarnEnabled)
     {
         log.WarnFormat("EXCEPTION, please implement {0}.ExceptionCaught() for proper handling: {1}", GetType().Name, cause);
     }
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:8,代码来源:IoHandlerAdapter.cs

示例7: Decode

        public void Decode(IoSession session, IoBuffer input, IProtocolDecoderOutput output)
        {
            if (_session == null)
                _session = session;
            else if (_session != session)
                throw new InvalidOperationException(GetType().Name + " is a stateful decoder.  "
                        + "You have to create one per session.");

            _undecodedBuffers.Enqueue(input);
            while (true)
            {
                IoBuffer b;
                if (!_undecodedBuffers.TryPeek(out b))
                    break;

                Int32 oldRemaining = b.Remaining;
                _state.Decode(b, output);
                Int32 newRemaining = b.Remaining;
                if (newRemaining != 0)
                {
                    if (oldRemaining == newRemaining)
                        throw new InvalidOperationException(_state.GetType().Name
                            + " must consume at least one byte per decode().");
                }
                else
                {
                    _undecodedBuffers.TryDequeue(out b);
                }
            }
        }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:30,代码来源:DecodingStateProtocolDecoder.cs

示例8: SampleCommand

      public SampleCommand(
          IoSession session,
          TimeoutNotifyProducerConsumer<AbstractAsyncCommand> producer)
          :base(session, CommandCode.Test, producer)
      {
 
      }
开发者ID:zesus19,项目名称:c5.v1,代码行数:7,代码来源:SampleCommand.cs

示例9: DecodeBody

        protected override AbstractMessage DecodeBody(IoSession session, IoBuffer input)
        {
            if (!_readCode)
            {
                if (input.Remaining < Constants.RESULT_CODE_LEN)
                {
                    return null; // Need more data.
                }

                _code = input.GetInt16();
                _readCode = true;
            }

            if (_code == Constants.RESULT_OK)
            {
                if (input.Remaining < Constants.RESULT_VALUE_LEN)
                {
                    return null;
                }

                ResultMessage m = new ResultMessage();
                m.OK = true;
                m.Value = input.GetInt32();
                _readCode = false;
                return m;
            }
            else
            {
                ResultMessage m = new ResultMessage();
                m.OK = false;
                _readCode = false;
                return m;
            }
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:34,代码来源:ResultMessageDecoder.cs

示例10: IsConnectionOk

        /// <summary>
        /// Method responsible for deciding if a connection is OK to continue.
        /// </summary>
        /// <param name="session">the new session that will be verified</param>
        /// <returns>true if the session meets the criteria, otherwise false</returns>
        public Boolean IsConnectionOk(IoSession session)
        {
            IPEndPoint ep = session.RemoteEndPoint as IPEndPoint;
            if (ep != null)
            {
                String addr = ep.Address.ToString();
                DateTime now = DateTime.Now;
                DateTime? lastConnTime = null;

                _clients.AddOrUpdate(addr, now, (k, v) =>
                {
                    if (log.IsDebugEnabled)
                        log.Debug("This is not a new client");
                    lastConnTime = v;
                    return now;
                });

                if (lastConnTime.HasValue)
                {
                    // if the interval between now and the last connection is
                    // less than the allowed interval, return false
                    if ((now - lastConnTime.Value).TotalMilliseconds < _allowedInterval)
                    {
                        if (log.IsWarnEnabled)
                            log.Warn("Session connection interval too short");
                        return false;
                    }
                }

                return true;
            }

            return false;
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:39,代码来源:ConnectionThrottleFilter.cs

示例11: Decodable

        public MessageDecoderResult Decodable(IoSession session, IoBuffer input)
        {
            if ((MessageType)input.Get() != MessageType.Update_ZipFiles)
            {
                return MessageDecoderResult.NotOK;
            }

            var zipFileInfo = JsonConvert.DeserializeObject<TransferingZipFileInfo>(input.GetString(Encoding.UTF8));
            var fileSize = zipFileInfo.FileSize;
            var hashBytes = zipFileInfo.HashBytes;
            if (input.Remaining < fileSize)
            {
                return MessageDecoderResult.NeedData;
            }

            var filesBytes = new byte[fileSize];
            input.Get(filesBytes, 0, (int)fileSize);

            if (FileHashHelper.CompareHashValue(FileHashHelper.ComputeFileHash(filesBytes), hashBytes))
            {
                _zipFileInfoMessage = new TransferingZipFile(filesBytes);
                return MessageDecoderResult.OK;
            }
            return MessageDecoderResult.NotOK;
        }
开发者ID:AnchoretTeam,项目名称:AppUpdate,代码行数:25,代码来源:TransferingZipFileProtocolDecoder.cs

示例12: Dispose

 public void Dispose(IoSession session)
 {
     lock (_encoder)
     {
         _encoder.Dispose(session);
     }
 }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:7,代码来源:SynchronizedProtocolEncoder.cs

示例13: Decode

        public MessageDecoderResult Decode(IoSession session, IoBuffer input, IProtocolDecoderOutput output)
        {
            // Try to skip header if not read.
            if (!_readHeader)
            {
                input.GetInt16(); // Skip 'type'.
                _sequence = input.GetInt32(); // Get 'sequence'.
                _readHeader = true;
            }

            // Try to decode body
            AbstractMessage m = DecodeBody(session, input);
            // Return NEED_DATA if the body is not fully read.
            if (m == null)
            {
                return MessageDecoderResult.NeedData;
            }
            else
            {
                _readHeader = false; // reset readHeader for the next decode
            }
            m.Sequence = _sequence;
            output.Write(m);

            return MessageDecoderResult.OK;
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:26,代码来源:AbstractMessageDecoder.cs

示例14: Write

        private void Write(IoSession session, IoBuffer data, IoBuffer buf)
        {
            try
            {
                Int32 len = data.Remaining;
                if (len >= buf.Capacity)
                {
                    /*
                     * If the request length exceeds the size of the output buffer,
                     * flush the output buffer and then write the data directly.
                     */
                    INextFilter nextFilter = session.FilterChain.GetNextFilter(this);
                    InternalFlush(nextFilter, session, buf);
                    nextFilter.FilterWrite(session, new DefaultWriteRequest(data));
                    return;
                }
                if (len > (buf.Limit - buf.Position))
                {
                    InternalFlush(session.FilterChain.GetNextFilter(this), session, buf);
                }

                lock (buf)
                {
                    buf.Put(data);
                }
            }
            catch (Exception e)
            {
                session.FilterChain.FireExceptionCaught(e);
            }
        }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:31,代码来源:BufferedWriteFilter.cs

示例15: Put

 public void Put(IoSession session)
 {
     _sessionMap.StartExpiring();
     EndPoint key = session.RemoteEndPoint;
     if (!_sessionMap.ContainsKey(key))
         _sessionMap.Add(key, session);
 }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:7,代码来源:ExpiringSessionRecycler.cs


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