예제 #1
0
        /// <summary>
        /// process a giop locate request message.
        /// </summary>
        private ServerProcessing ProcessLocateRequestMessage(IServerChannelSinkStack sinkStack,
                                                             ITransportHeaders requestHeaders,
                                                             CdrMessageInputStream msgInput,
                                                             GiopServerConnection serverCon,
                                                             out IMessage responseMsg, out ITransportHeaders responseHeaders,
                                                             out Stream responseStream)
        {
            responseHeaders = null;
            LocateRequestMessage deserReqMsg =
                m_messageHandler.ParseIncomingLocateRequestMessage(msgInput);

            // TODO: dummy implementation, don't check yet
            LocateReplyMessage response = new LocateReplyMessage(LocateStatus.OBJECT_HERE);

            responseMsg = response;
            PrepareResponseHeaders(ref responseHeaders, serverCon);
            // get the stream into which the message should be serialied from a stream handling
            // sink in the stream handling chain
            responseStream = GetResponseStreamFor(sinkStack, responseMsg, responseHeaders);

            m_messageHandler.SerialiseOutgoingLocateReplyMessage(response, deserReqMsg,
                                                                 msgInput.Header.Version,
                                                                 responseStream, serverCon.ConDesc);
            return(ServerProcessing.Complete);
        }
예제 #2
0
        public void TestLocateReplySerialisation()
        {
            uint requestId = 5;

            byte[]               objectKey = new byte[] { 116, 101, 115, 116, 111, 98, 106, 101, 99, 116 }; // testobject
            string               targetUri = "testobject";
            GiopVersion          version   = new GiopVersion(1, 2);
            LocateRequestMessage locReq    = new LocateRequestMessage(requestId, objectKey, targetUri);
            // create a connection context
            GiopConnectionDesc conDesc = new GiopConnectionDesc(null, null);

            // create the reply
            LocateStatus       replyStatus = LocateStatus.OBJECT_HERE;
            LocateReplyMessage locReply    = new LocateReplyMessage(replyStatus);

            MemoryStream targetStream = new MemoryStream();

            m_handler.SerialiseOutgoingLocateReplyMessage(locReply, locReq, version, targetStream, conDesc);

            // check to serialised stream
            targetStream.Seek(0, SeekOrigin.Begin);

            CdrInputStreamImpl cdrIn = new CdrInputStreamImpl(targetStream);

            cdrIn.ConfigStream(0, version);

            // first is Giop-magic
            byte data;

            AssertBytesFollowing(m_giopMagic, cdrIn);
            // Giop version
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(1, data);
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(2, data);
            // flags: big-endian, no fragements
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual(0, data);
            // Giop Msg type: locate reply
            data = (byte)cdrIn.ReadOctet();
            Assert.AreEqual((byte)GiopMsgTypes.LocateReply, data);
            // Giop Msg length
            uint msgLength = cdrIn.ReadULong();

            cdrIn.SetMaxLength(msgLength);
            // req-id
            Assert.AreEqual(requestId, cdrIn.ReadULong());
            // the location status
            Assert.AreEqual((uint)replyStatus, cdrIn.ReadULong());
        }