client-cpp  0.6.3
DefaultBootstrapChannel.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 DEFAULTBOOTSTRAPCHANNEL_HPP_
18 #define DEFAULTBOOTSTRAPCHANNEL_HPP_
19 
20 #include "kaa/KaaDefaults.hpp"
21 
22 #ifdef KAA_DEFAULT_BOOTSTRAP_HTTP_CHANNEL
23 
25 
26 namespace kaa {
27 
28 class DefaultBootstrapChannel : public AbstractHttpChannel {
29 public:
30  DefaultBootstrapChannel(IKaaChannelManager *channelManager, const KeyPair& clientKeys) : AbstractHttpChannel(channelManager, clientKeys) { }
31  virtual ~DefaultBootstrapChannel() { }
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(IPTransportInfoPtr server, const std::vector<std::uint8_t>& body)
38  {
39  HttpDataProcessor *processor = getHttpDataProcessor();
40  auto request = processor->createBootstrapRequest(server->getURL() + getURLSuffix(), body);
41  return request;
42  }
43 
44  virtual std::string retrieveResponse(const IHttpResponse& response)
45  {
46  return getHttpDataProcessor()->retrieveBootstrapResponse(response);
47  }
48 
49  virtual ServerType getServerType() const {
50  return ServerType::BOOTSTRAP;
51  }
52 
53 protected:
54  virtual std::string getURLSuffix() {
55  return "/BS/Sync";
56  }
57 
58 private:
59  static const std::string CHANNEL_ID;
60  static const std::map<TransportType, ChannelDirection> SUPPORTED_TYPES;
61 };
62 
63 }
64 
65 #endif
66 
67 #endif /* DEFAULTBOOTSTRAPCHANNEL_HPP_ */
ServerType
Definition: ServerType.hpp:22