Example #1
0
        /// <summary>
        /// reads a locate-request message.
        /// </summary>
        internal LocateRequestMessage ParseIncomingLocateRequestMessage(CdrMessageInputStream msgInput)
        {
            CdrInputStream msgBody = msgInput.GetMessageContentReadingStream();
            // deserialize message body
            LocateRequestMessage result = m_ser.DeserialiseLocateRequest(msgBody, msgInput.Header.Version);

            Debug.WriteLine("locate request for target-uri: " + result.TargetUri);
            return(result);
        }
        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());
        }
 /// <summary>
 /// reads a locate-request message from the message input stream msgInput
 /// and formulates an answer.
 /// </summary>
 /// <returns></returns>
 internal Stream SerialiseOutgoingLocateReplyMessage(LocateReplyMessage replyMsg, LocateRequestMessage requestMsg,
                                                     GiopVersion version,
                                                     Stream targetStream, GiopConnectionDesc conDesc) {
     GiopHeader header = new GiopHeader(version.Major, version.Minor, m_headerFlags, GiopMsgTypes.LocateReply);
     CdrMessageOutputStream msgOutput = new CdrMessageOutputStream(targetStream, header);
     // serialize the message
     m_ser.SerialiseLocateReply(msgOutput.GetMessageContentWritingStream(), version,
                                requestMsg.RequestId, replyMsg);
     msgOutput.CloseStream(); // write to the stream
     return targetStream;
 }
Example #4
0
        /// <summary>
        /// reads a locate-request message from the message input stream msgInput
        /// and formulates an answer.
        /// </summary>
        /// <returns></returns>
        internal Stream SerialiseOutgoingLocateReplyMessage(LocateReplyMessage replyMsg, LocateRequestMessage requestMsg,
                                                            GiopVersion version,
                                                            Stream targetStream, GiopConnectionDesc conDesc)
        {
            GiopHeader             header    = new GiopHeader(version.Major, version.Minor, m_headerFlags, GiopMsgTypes.LocateReply);
            CdrMessageOutputStream msgOutput = new CdrMessageOutputStream(targetStream, header);

            // serialize the message
            m_ser.SerialiseLocateReply(msgOutput.GetMessageContentWritingStream(), version,
                                       requestMsg.RequestId, replyMsg);
            msgOutput.CloseStream(); // write to the stream
            return(targetStream);
        }