/// <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); }
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()); }
public void TestLocateRequestDeserialisation() { MemoryStream sourceStream = new MemoryStream(); // prepare msg uint requestId = 5; GiopVersion version = new GiopVersion(1, 2); CdrOutputStreamImpl cdrOut = new CdrOutputStreamImpl(sourceStream, 0, version); cdrOut.WriteOpaque(m_giopMagic); // version cdrOut.WriteOctet(version.Major); cdrOut.WriteOctet(version.Minor); // flags cdrOut.WriteOctet(0); // msg-type: request cdrOut.WriteOctet((byte)GiopMsgTypes.LocateRequest); // msg-length cdrOut.WriteULong(22); // request-id cdrOut.WriteULong(requestId); // target: key type cdrOut.WriteULong(0); cdrOut.WriteULong(10); // key length byte[] objectKey = new byte[] { 116, 101, 115, 116, 111, 98, 106, 101, 99, 116 }; // testobject cdrOut.WriteOpaque(objectKey); // create a connection context: this is needed for request deserialisation GiopConnectionDesc conDesc = new GiopConnectionDesc(null, null); // go to stream begin sourceStream.Seek(0, SeekOrigin.Begin); // deserialise request message LocateRequestMessage result = m_handler.ParseIncomingLocateRequestMessage(sourceStream); // now check if values are correct Assert.IsTrue(result != null, "deserialised message is null"); Assert.AreEqual(requestId, result.RequestId); Assert.NotNull(result.ObjectKey); Assert.NotNull(result.TargetUri); Assert.AreEqual("testobject", result.TargetUri); }