client-cpp  0.6.1
DefaultOperationHttpChannel.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef DEFAULTOPERATIONHTTPCHANNEL_HPP_
18 #define DEFAULTOPERATIONHTTPCHANNEL_HPP_
19 
20 #include "kaa/KaaDefaults.hpp"
21 
22 #ifdef KAA_DEFAULT_OPERATION_HTTP_CHANNEL
23 
25 
26 namespace kaa {
27 
28 class DefaultOperationHttpChannel : public AbstractHttpChannel<ChannelType::HTTP> {
29 public:
30  DefaultOperationHttpChannel(IKaaChannelManager *channelManager, const KeyPair& clientKeys) : AbstractHttpChannel(channelManager, clientKeys) { }
31  virtual ~DefaultOperationHttpChannel() { }
32 
33  virtual const std::string& getId() const { return CHANNEL_ID; }
34  virtual const std::map<TransportType, ChannelDirection>& getSupportedTransportTypes() const { return SUPPORTED_TYPES; }
35 
36 private:
37  virtual std::shared_ptr<IHttpRequest> createRequest(AbstractServerInfoPtr server, const std::vector<std::uint8_t>& body)
38  {
39  return getHttpDataProcessor()->createOperationRequest(server->getUrl(), body);
40  }
41 
42  virtual std::string retrieveResponse(const IHttpResponse& response)
43  {
44  if (response.getStatusCode() != 200) {
45  throw TransportException(boost::format("Invalid response code %1%") % response.getStatusCode());
46  }
47  return getHttpDataProcessor()->retrieveOperationResponse(response);
48  }
49 
50  virtual ServerType getServerType() const {
52  }
53 
54 private:
55  static const std::string CHANNEL_ID;
56  static const std::map<TransportType, ChannelDirection> SUPPORTED_TYPES;
57 };
58 
59 }
60 
61 #endif
62 
63 #endif /* DEFAULTOPERATIONHTTPCHANNEL_HPP_ */
std::pair< Botan::MemoryVector< std::uint8_t >, std::string > KeyPair
Definition: KeyUtils.hpp:29
ServerType
Definition: ServerType.hpp:22