예제 #1
0
        public void abortBatchRequest()
        {
            _m.Lock();
            try
            {
                if (!initialized())
                {
                    Debug.Assert(_batchRequestInProgress);
                    _batchRequestInProgress = false;
                    _m.NotifyAll();

                    BasicStream dummy = new BasicStream(_reference.getInstance(), Ice.Util.currentProtocolEncoding,
                                                        _batchAutoFlush);
                    _batchStream.swap(dummy);
                    _batchRequestsSize = Protocol.requestBatchHdr.Length;

                    return;
                }
            }
            finally
            {
                _m.Unlock();
            }
            _connection.abortBatchRequest();
        }
예제 #2
0
        public void finishBatchRequest(BasicStream os)
        {
            _m.Lock();
            try
            {
                if (!initialized())
                {
                    Debug.Assert(_batchRequestInProgress);
                    _batchRequestInProgress = false;
                    _m.NotifyAll();

                    _batchStream.swap(os);

                    if (!_batchAutoFlush &&
                        _batchStream.size() + _batchRequestsSize > _reference.getInstance().messageSizeMax())
                    {
                        Ex.throwMemoryLimitException(_batchStream.size() + _batchRequestsSize,
                                                     _reference.getInstance().messageSizeMax());
                    }
                    _requests.AddLast(new Request(_batchStream));
                    return;
                }
            }
            finally
            {
                _m.Unlock();
            }
            _connection.finishBatchRequest(os, _compress);
        }
예제 #3
0
        public int Read(byte[] buffer, int offset, int count)
        {
            int read = 0;

            if (BasicStream != null) // not yet created
            {
                if (SyncPosition != null)
                {
                    SyncPosition(_BasicStream);
                }
                if (BasicStream.Position < UnreadableHead)
                {
                    BasicStream.Position = UnreadableHead;
                }
                if (CurrentPosition + count < AvaliableLength)
                {
                    read = BasicStream.Read(buffer, offset, count);
                }
                else if (CurrentPosition < AvaliableLength)
                {
                    read = BasicStream.Read(buffer, offset, (int)(AvaliableLength - CurrentPosition));
                }
            }
            if (read < count)
            {
                // zero the end of the buffer
                Array.Clear(buffer, offset + read, count - read);
                read = count;
            }
            return(read);
        }
예제 #4
0
 public override void streamWrite(BasicStream s)
 {
     s.startWriteEncaps();
     _delegate.streamWriteImpl(s);
     s.writeString(_resource);
     s.endWriteEncaps();
 }
예제 #5
0
        public EndpointI read(BasicStream s)
        {
            lock (this)
            {
                short type = s.readShort();

                EndpointFactory factory = get(type);
                EndpointI       e       = null;

                s.startReadEncaps();

                if (factory != null)
                {
                    e = factory.read(s);
                }
                else
                {
                    e = new OpaqueEndpointI(type, s);
                }

                s.endReadEncaps();

                return(e);
            }
        }
예제 #6
0
        internal WSEndpoint(ProtocolInstance instance, EndpointI del, BasicStream s)
        {
            _instance = instance;
            _delegate = (IPEndpointI)del;

            _resource = s.readString();
        }
예제 #7
0
        private static void printRequestHeader(System.IO.StringWriter s, BasicStream str)
        {
            printIdentityFacetOperation(s, str);

            try
            {
                byte mode = str.readByte();
                s.Write("\nmode = " + (int)mode + ' ');
                switch ((Ice.OperationMode)mode)
                {
                case Ice.OperationMode.Normal:
                {
                    s.Write("(normal)");
                    break;
                }

                case Ice.OperationMode.Nonmutating:
                {
                    s.Write("(nonmutating)");
                    break;
                }

                case Ice.OperationMode.Idempotent:
                {
                    s.Write("(idempotent)");
                    break;
                }

                default:
                {
                    s.Write("(unknown)");
                    break;
                }
                }

                int sz = str.readSize();
                s.Write("\ncontext = ");
                while (sz-- > 0)
                {
                    string key = str.readString();
                    string val = str.readString();
                    s.Write(key + '/' + val);
                    if (sz > 0)
                    {
                        s.Write(", ");
                    }
                }

                Ice.EncodingVersion v = str.skipEncaps();
                if (!v.Equals(Ice.Util.Encoding_1_0))
                {
                    s.Write("\nencoding = ");
                    s.Write(Ice.Util.encodingVersionToString(v));
                }
            }
            catch (System.IO.IOException)
            {
                Debug.Assert(false);
            }
        }
예제 #8
0
파일: Incoming.cs 프로젝트: stick/zeroc-ice
        public void writeUserException__(Ice.UserException ex, Ice.FormatType format)
        {
            BasicStream os__ = startWriteParams__(format);

            os__.writeUserException(ex);
            endWriteParams__(false);
        }
예제 #9
0
 //
 // Marshal the endpoint
 //
 public override void streamWrite(BasicStream s)
 {
     s.writeShort(_type);
     s.startWriteEncaps(_rawEncoding, Ice.FormatType.DefaultFormat);
     s.writeBlob(_rawBytes);
     s.endWriteEncaps();
 }
예제 #10
0
파일: Incoming.cs 프로젝트: stick/zeroc-ice
        //
        // These functions allow this object to be reused, rather than reallocated.
        //
        public virtual void reset(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter,
                                  bool response, byte compress, int requestId)
        {
            instance_ = instance;

            //
            // Don't recycle the Current object, because servants may keep a reference to it.
            //
            current_           = new Ice.Current();
            current_.id        = new Ice.Identity();
            current_.adapter   = adapter;
            current_.con       = connection;
            current_.requestId = requestId;

            Debug.Assert(cookie_ == null);

            response_ = response;

            compress_ = compress;

            if (response_ && os_ == null)
            {
                os_ = new BasicStream(instance, Ice.Util.currentProtocolEncoding);
            }

            connection_ = connection;
            interceptorAsyncCallbackList_ = null;
        }
예제 #11
0
파일: Outgoing.cs 프로젝트: stick/zeroc-ice
 public BatchOutgoing(Ice.ConnectionI connection, Instance instance, InvocationObserver observer)
 {
     _connection = connection;
     _sent       = false;
     _observer   = observer;
     _os         = new BasicStream(instance, Ice.Util.currentProtocolEncoding);
 }
예제 #12
0
 public OnewayOutgoingAsync(Ice.ObjectPrxHelperBase prx, string operation, ProxyOnewayCallback <T> cb,
                            object cookie, BasicStream iss, BasicStream os) :
     base(prx, operation, cookie, iss, os)
 {
     Debug.Assert(cb != null);
     _completed = cb;
 }
예제 #13
0
        private static byte printHeader(System.IO.StringWriter s, BasicStream str)
        {
            try
            {
                str.readByte(); // Don't bother printing the magic number
                str.readByte();
                str.readByte();
                str.readByte();

                /* byte pMajor = */ str.readByte();
                /* byte pMinor = */ str.readByte();
                //s.Write("\nprotocol version = " + (int)pMajor + "." + (int)pMinor);

                /* byte eMajor = */ str.readByte();
                /* byte eMinor = */ str.readByte();
                //s.Write("\nencoding version = " + (int)eMajor + "." + (int)eMinor);

                byte type = str.readByte();
                s.Write("\nmessage type = " + (int)type + " (" + getMessageTypeAsString(type) + ')');

                byte compress = str.readByte();
                s.Write("\ncompression status = " + (int)compress + ' ');
                switch (compress)
                {
                case (byte)0:
                {
                    s.Write("(not compressed; do not compress response, if any)");
                    break;
                }

                case (byte)1:
                {
                    s.Write("(not compressed; compress response, if any)");
                    break;
                }

                case (byte)2:
                {
                    s.Write("(compressed; compress response, if any)");
                    break;
                }

                default:
                {
                    s.Write("(unknown)");
                    break;
                }
                }

                int size = str.readInt();
                s.Write("\nmessage size = " + size);
                return(type);
            }
            catch (System.IO.IOException)
            {
                Debug.Assert(false);
                return(0);
            }
        }
예제 #14
0
파일: Outgoing.cs 프로젝트: stick/zeroc-ice
 public BatchOutgoing(RequestHandler handler, InvocationObserver observer)
 {
     _handler  = handler;
     _sent     = false;
     _observer = observer;
     _os       = new BasicStream(handler.getReference().getInstance(), Ice.Util.currentProtocolEncoding);
     Protocol.checkSupportedProtocol(handler.getReference().getProtocol());
 }
예제 #15
0
파일: IPEndpointI.cs 프로젝트: sk163/ice-1
 public IPEndpointI(ProtocolInstance instance, BasicStream s)
 {
     instance_        = instance;
     host_            = s.readString();
     port_            = s.readInt();
     sourceAddr_      = null;
     connectionId_    = "";
     _hashInitialized = false;
 }
예제 #16
0
        public Ice.ObjectPrx streamToProxy(BasicStream s)
        {
            Ice.Identity ident = new Ice.Identity();
            ident.read__(s);

            Reference r = instance_.referenceFactory().create(ident, s);

            return(referenceToProxy(r));
        }
예제 #17
0
 //
 // Writeable stream constructor
 //
 public StreamWrapper(BasicStream s)
 {
     type_   = StreamType.Write;
     s_      = s;
     spos_   = s.pos();
     bytes_  = new byte[254];
     pos_    = 0;
     length_ = 0;
 }
예제 #18
0
 //
 // Readable stream constructor
 //
 public StreamWrapper(int size, BasicStream s)
 {
     type_   = StreamType.Read;
     s_      = s;
     spos_   = 0;
     bytes_  = null;
     pos_    = 0;
     length_ = size;
 }
예제 #19
0
 //
 // Marshal the endpoint
 //
 public override void streamWrite(BasicStream s)
 {
     s.writeShort(Ice.TCPEndpointType.value);
     s.startWriteEncaps();
     s.writeString(_host);
     s.writeInt(_port);
     s.writeInt(_timeout);
     s.writeBool(_compress);
     s.endWriteEncaps();
 }
예제 #20
0
        private static IEnumerable <string> ReadLines(params string[] lines)
        {
            WrappedMemoryStream s = Lines(lines);

            Task <BasicLine[]> task = BasicStream.ReadAsync(s);

            task.IsCompletedSuccessfully.Should().BeTrue();
            s.DisposeCount.Should().Be(1);
            return(task.Result.Select(l => l.ToString()));
        }
예제 #21
0
        public OpaqueEndpointI(short type, BasicStream s)
        {
            _type        = type;
            _rawEncoding = s.startReadEncaps();
            int sz = s.getReadEncapsSize();

            _rawBytes = new byte[sz];
            s.readBlob(_rawBytes);
            s.endReadEncaps();
            calcHashValue();
        }
예제 #22
0
 public TcpEndpointI(BasicStream s)
 {
     _instance = s.instance();
     s.startReadEncaps();
     _host     = s.readString();
     _port     = s.readInt();
     _timeout  = s.readInt();
     _compress = s.readBool();
     s.endReadEncaps();
     calcHashValue();
 }
예제 #23
0
        private static void printRequest(System.IO.StringWriter s, BasicStream str)
        {
            int requestId = str.readInt();

            s.Write("\nrequest id = " + requestId);
            if (requestId == 0)
            {
                s.Write(" (oneway)");
            }

            printRequestHeader(s, str);
        }
예제 #24
0
 //
 // Marshal the endpoint
 //
 public override void streamWriteImpl(BasicStream s)
 {
     base.streamWriteImpl(s);
     if (s.getWriteEncoding().Equals(Ice.Util.Encoding_1_0))
     {
         Ice.Util.Protocol_1_0.write__(s);
         Ice.Util.Encoding_1_0.write__(s);
     }
     // Not transmitted.
     //s.writeBool(_connect);
     s.writeBool(_compress);
 }
예제 #25
0
        private static void printBatchRequest(System.IO.StringWriter s, BasicStream str)
        {
            int batchRequestNum = str.readInt();

            s.Write("\nnumber of requests = " + batchRequestNum);

            for (int i = 0; i < batchRequestNum; ++i)
            {
                s.Write("\nrequest #" + i + ':');
                printRequestHeader(s, str);
            }
        }
예제 #26
0
        public static void dumpStream(BasicStream stream)
        {
            int pos = stream.pos();

            stream.pos(0);

            byte[] data = new byte[stream.size()];
            stream.readBlob(data);
            dumpOctets(data);

            stream.pos(pos);
        }
예제 #27
0
 abortBatchRequest(BasicStream os)
 {
     lock (this)
     {
         if (_batchStreamInUse)
         {
             _batchStream.swap(os);
             _batchStream.resize(_batchMarker, false);
             _batchStreamInUse = false;
             System.Threading.Monitor.PulseAll(this);
         }
     }
 }
예제 #28
0
 prepareBatchRequest(BasicStream os)
 {
     lock (this)
     {
         if (_exception != null)
         {
             throw _exception;
         }
         waitStreamInUse(false);
         _batchStreamInUse = true;
         _batchStream.swap(os);
     }
 }
예제 #29
0
파일: Outgoing.cs 프로젝트: stick/zeroc-ice
        public Outgoing(RequestHandler handler, string operation, Ice.OperationMode mode,
                        Dictionary <string, string> context, InvocationObserver observer)
        {
            _state    = StateUnsent;
            _sent     = false;
            _handler  = handler;
            _observer = observer;
            _encoding = Protocol.getCompatibleEncoding(handler.getReference().getEncoding());
            _os       = new BasicStream(_handler.getReference().getInstance(), Ice.Util.currentProtocolEncoding);

            Protocol.checkSupportedProtocol(Protocol.getCompatibleProtocol(_handler.getReference().getProtocol()));

            writeHeader(operation, mode, context);
        }
예제 #30
0
 public UdpEndpointI(ProtocolInstance instance, BasicStream s) :
     base(instance, s)
 {
     if (s.getReadEncoding().Equals(Ice.Util.Encoding_1_0))
     {
         s.readByte();
         s.readByte();
         s.readByte();
         s.readByte();
     }
     // Not transmitted.
     //_connect = s.readBool();
     _connect  = false;
     _compress = s.readBool();
 }