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


C# IceInternal.attachRemoteObserver方法代码示例

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


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

示例1: sendAsyncRequest

        public bool sendAsyncRequest(IceInternal.OutgoingAsyncBase og, bool compress, bool response,
                                     int batchRequestNum, out Ice.AsyncCallback sentCallback)
        {
            IceInternal.BasicStream os = og.getOs();

            lock(this)
            {
                if(_exception != null)
                {
                    //
                    // If the connection is closed before we even have a chance
                    // to send our request, we always try to send the request
                    // again.
                    //
                    throw new IceInternal.RetryException(_exception);
                }

                Debug.Assert(_state > StateNotValidated);
                Debug.Assert(_state < StateClosing);

                //
                // Ensure the message isn't bigger than what we can send with the
                // transport.
                //
                _transceiver.checkSendSize(os.getBuffer());

                //
                // Notify the request that it's cancelable with this connection.
                // This will throw if the request is canceled.
                //
                og.cancelable(this);

                int requestId = 0;
                if(response)
                {
                    //
                    // Create a new unique request ID.
                    //
                    requestId = _nextRequestId++;
                    if(requestId <= 0)
                    {
                        _nextRequestId = 1;
                        requestId = _nextRequestId++;
                    }

                    //
                    // Fill in the request ID.
                    //
                    os.pos(IceInternal.Protocol.headerSize);
                    os.writeInt(requestId);
                }
                else if(batchRequestNum > 0)
                {
                    os.pos(IceInternal.Protocol.headerSize);
                    os.writeInt(batchRequestNum);
                }

                og.attachRemoteObserver(initConnectionInfo(), _endpoint, requestId);

                bool sent;
                try
                {
                    OutgoingMessage msg = new OutgoingMessage(og, os, compress, requestId);
                    sent = sendMessage(msg);
                    sentCallback = msg.sentCallback;
                }
                catch(LocalException ex)
                {
                    setState(StateClosed, ex);
                    Debug.Assert(_exception != null);
                    throw _exception;
                }

                if(response)
                {
                    //
                    // Add to the async requests map.
                    //
                    _asyncRequests[requestId] = og;
                }
                return sent;
            }
        }
开发者ID:alexmnazarenko,项目名称:ice,代码行数:83,代码来源:ConnectionI.cs

示例2: sendRequest

        public bool sendRequest(IceInternal.Outgoing og, bool compress, bool response)
        {
            IceInternal.BasicStream os = og.ostr();

            _m.Lock();
            try
            {
                if(_exception != null)
                {
                    //
                    // If the connection is closed before we even have a chance
                    // to send our request, we always try to send the request
                    // again.
                    //
                    throw new IceInternal.LocalExceptionWrapper(_exception, true);
                }

                Debug.Assert(_state > StateNotValidated);
                Debug.Assert(_state < StateClosing);

                //
                // Ensure the message isn't bigger than what we can send with the
                // transport.
                //
                _transceiver.checkSendSize(os.getBuffer(), _instance.messageSizeMax());

                int requestId = 0;
                if(response)
                {
                    //
                    // Create a new unique request ID.
                    //
                    requestId = _nextRequestId++;
                    if(requestId <= 0)
                    {
                        _nextRequestId = 1;
                        requestId = _nextRequestId++;
                    }

                    //
                    // Fill in the request ID.
                    //
                    os.pos(IceInternal.Protocol.headerSize);
                    os.writeInt(requestId);
                }

                og.attachRemoteObserver(initConnectionInfo(), _endpoint, requestId, 
                                        os.size() - IceInternal.Protocol.headerSize - 4);

                //
                // Send the message. If it can't be sent without blocking the message is added
                // to _sendStreams and it will be sent by the asynchronous I/O callback.
                //
                bool sent = false;
                try
                {
                    sent = sendMessage(new OutgoingMessage(og, os, compress, requestId));
                }
                catch(LocalException ex)
                {
                    setState(StateClosed, ex);
                    Debug.Assert(_exception != null);
                    throw _exception;
                }

                if(response)
                {
                    //
                    // Add to the requests map.
                    //
                    _requests[requestId] = og;
                }

                return sent;
            }
            finally
            {
                _m.Unlock();
            }
        }
开发者ID:sbesson,项目名称:zeroc-ice,代码行数:80,代码来源:ConnectionI.cs

示例3: flushBatchRequests

        public bool flushBatchRequests(IceInternal.BatchOutgoing @out)
        {
            _m.Lock();
            try
            {
                while(_batchStreamInUse && _exception == null)
                {
                    _m.Wait();
                }

                if(_exception != null)
                {
                    throw _exception;
                }

                if(_batchRequestNum == 0)
                {
                    @out.sent(false);
                    return true;
                }

                //
                // Fill in the number of requests in the batch.
                //
                _batchStream.pos(IceInternal.Protocol.headerSize);
                _batchStream.writeInt(_batchRequestNum);

                @out.attachRemoteObserver(initConnectionInfo(), _endpoint, 
                                          _batchStream.size() - IceInternal.Protocol.headerSize);

                _batchStream.swap(@out.ostr());

                bool sent = false;
                try
                {
                    OutgoingMessage message = new OutgoingMessage(@out, @out.ostr(), _batchRequestCompress, 0);
                    sent = sendMessage(message);
                }
                catch(LocalException ex)
                {
                    setState(StateClosed, ex);
                    Debug.Assert(_exception != null);
                    throw _exception;
                }

                //
                // Reset the batch stream.
                //
                _batchStream = new IceInternal.BasicStream(_instance, Util.currentProtocolEncoding, _batchAutoFlush);
                _batchRequestNum = 0;
                _batchRequestCompress = false;
                _batchMarker = 0;

                return sent;
            }
            finally
            {
                _m.Unlock();
            }
        }
开发者ID:sbesson,项目名称:zeroc-ice,代码行数:60,代码来源:ConnectionI.cs

示例4: flushAsyncBatchRequests

        public bool flushAsyncBatchRequests(IceInternal.OutgoingAsyncBase outAsync, out Ice.AsyncCallback sentCallback)
        {
            lock(this)
            {
                while(_batchStreamInUse && _exception == null)
                {
                    System.Threading.Monitor.Wait(this);
                }

                if(_exception != null)
                {
                    throw _exception;
                }

                if(_batchRequestNum == 0)
                {
                    sentCallback = outAsync.sent();
                    return true;
                }

                //
                // Notify the request that it's cancelable with this connection. 
                // This will throw if the request is canceled.
                //
                outAsync.cancelable(this);

                //
                // Fill in the number of requests in the batch.
                //
                _batchStream.pos(IceInternal.Protocol.headerSize);
                _batchStream.writeInt(_batchRequestNum);

                _batchStream.swap(outAsync.getOs());

                outAsync.attachRemoteObserver(initConnectionInfo(), _endpoint, 0);

                //
                // Send the batch stream.
                //
                bool sent;
                try
                {
                    OutgoingMessage message = new OutgoingMessage(outAsync, outAsync.getOs(), _batchRequestCompress, 0);
                    sent = sendMessage(message);
                    sentCallback = message.sentCallback;
                }
                catch(LocalException ex)
                {
                    setState(StateClosed, ex);
                    Debug.Assert(_exception != null);
                    throw _exception;
                }
                
                //
                // Reset the batch stream.
                //
                _batchStream = new IceInternal.BasicStream(_instance, Util.currentProtocolEncoding);
                _batchRequestNum = 0;
                _batchRequestCompress = false;
                _batchMarker = 0;
                return sent;
            }
        }
开发者ID:pedia,项目名称:zeroc-ice,代码行数:63,代码来源:ConnectionI.cs


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