activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r547769 - in /activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp: StompResponseBuilder.cpp StompResponseBuilder.h
Date Fri, 15 Jun 2007 19:16:51 GMT
Author: tabish
Date: Fri Jun 15 12:16:50 2007
New Revision: 547769

URL: http://svn.apache.org/viewvc?view=rev&rev=547769
Log:
https://issues.apache.org/activemq/browse/AMQCPP-130

Added:
    activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.cpp
    activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.h

Added: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.cpp?view=auto&rev=547769
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.cpp
(added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.cpp
Fri Jun 15 12:16:50 2007
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "StompResponseBuilder.h"
+
+#include <activemq/connector/stomp/commands/ConnectCommand.h>
+#include <activemq/connector/stomp/commands/ConnectedCommand.h>
+
+using namespace activemq;
+using namespace activemq::connector;
+using namespace activemq::connector::stomp;
+using namespace activemq::transport;
+
+////////////////////////////////////////////////////////////////////////////////
+Response* StompResponseBuilder::buildResponse( const transport::Command* cmd ){
+
+    // If this command requires a response we don't know what it is
+    // so we throw an exception.
+    if( cmd->isResponseRequired() ) {
+
+        throw transport::CommandIOException( __FILE__, __LINE__,
+            "StompResponseBuilder - unrecognized command" );
+    }
+
+    return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Command* StompResponseBuilder::buildIncomingCommand( const transport::Command* cmd ){
+
+    const commands::ConnectCommand* connectCommand =
+        dynamic_cast<const commands::ConnectCommand*>(cmd);
+
+    if( connectCommand != NULL ){
+        commands::ConnectedCommand* resp = new commands::ConnectedCommand();
+        resp->setCorrelationId( connectCommand->getCommandId() );
+
+        if( connectCommand->getClientId() == NULL )
+        {
+            resp->setSessionId( sessionId );
+        }
+        else
+        {
+            resp->setSessionId( connectCommand->getClientId() );
+        }
+
+        return resp;
+    }
+
+    return NULL;
+}

Added: activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.h?view=auto&rev=547769
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.h (added)
+++ activemq/activemq-cpp/trunk/src/main/activemq/connector/stomp/StompResponseBuilder.h Fri
Jun 15 12:16:50 2007
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ACTIVEMQ_CONNECTOR_STOMP_STOMPRESPONSEBUILDER_H_
+#define ACTIVEMQ_CONNECTOR_STOMP_STOMPRESPONSEBUILDER_H_
+
+#include <activemq/transport/MockTransport.h>
+
+namespace activemq{
+namespace connector{
+namespace stomp{
+
+    class StompResponseBuilder : public transport::MockTransport::ResponseBuilder{
+
+    private:
+
+        std::string sessionId;
+
+    public:
+
+        StompResponseBuilder( const std::string& sessionId ){
+            this->sessionId = sessionId;
+        }
+
+        virtual ~StompResponseBuilder(){}
+
+        virtual transport::Response* buildResponse( const transport::Command* cmd );
+        virtual transport::Command* buildIncomingCommand( const transport::Command* cmd );
+
+    };
+
+}}}
+
+#endif /*ACTIVEMQ_CONNECTOR_STOMP_STOMPRESPONSEBUILDER_H_*/



Mime
View raw message