RDK Documentation (Open Sourced RDK Components)
ServerMessageProcessor.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 /**
22 * @defgroup trm
23 * @{
24 * @defgroup qtapp
25 * @{
26 **/
27 
28 
29 #ifndef TRM_SERVER_MESSAGE_PROCESSOR_H_
30 #define TRM_SERVER_MESSAGE_PROCESSOR_H_
31 
32 #include <limits>
33 
34 ///#include <QObject>
35 #include <map>
36 
37 #include "trm/TRM.h"
38 #include "trm/TunerReservation.h"
39 #include "trm/MessageProcessor.h"
40 #include "trm/AsyncNotification.h"
41 
42 #include "Tuner.h"
43 #include "Executors.h"
44 #include "Connection.h"
45 
46 TRM_BEGIN_NAMESPACE
47 
49 {
50 public:
51 
52  ServerMessageProcessor(const Connection *connection = 0, int clientId = 0) :
53  connection(connection), clientId(clientId) {};
54 
55  template<class MsgT>
56  void process(const MsgT &msg) {
57  Executor<MsgT> exec(msg, clientId);
58  exec();
59  {
60 #if 0
61  std::vector<uint8_t> out(Header::kHeaderLength, 0);
62  JsonEncoder().encode(exec.getResponse(), out);
63  out.push_back('\0');
64  std::cout << (const char *)(&out[Header::kHeaderLength]) << "\r\n";
65  out.pop_back(); // Some json parser had issue with extra '\0' byte;
66  //Now send response bytes out to connection.
67  if (connection) {
68  std::vector<uint8_t> headerBytes;
69  Header header(Response, clientId, out.size() - Header::kHeaderLength);
70  header.serialize(headerBytes);
71  memcpy(&out[0], &headerBytes[0], Header::kHeaderLength);
72  connection->send(out);
73  }
74 #endif
75  }
76  }
77 
78  void operator() (const ReserveTuner &msg);
79  void operator() (const ReleaseTunerReservation &msg);
80  void operator() (const ValidateTunerReservation &msg);
81  void operator() (const CancelRecording &msg);
82  void operator() (const CancelRecordingResponse &msg);
83  void operator() (const GetAllTunerIds &msg);
84  void operator() (const GetAllTunerStates &msg);
85  void operator() (const GetAllReservations &msg);
86  void operator() (const GetVersion &msg);
87  void operator() (const CancelLive &msg);
88  void operator() (const CancelLiveResponse &msg);
89  void operator() (const UpdateTunerActivityStatus &msg);
90 
91 private:
92 
93 
94 private:
95  const Connection * connection;
96  int clientId;
97 
98 private:
99 };
100 
101 TRM_END_NAMESPACE
102 
103 #endif
104 
105 
106 /** @} */
107 /** @} */
ServerMessageProcessor
#include <QObject>
Definition: ServerMessageProcessor.h:48
Connection::send
void send(const CECFrame &frame, int timeout, const Throw_e &doThrow)
This function is used to send CEC frame to CEC Bus.
Definition: Connection.cpp:208
MessageProcessor
The MessageProcessor class implements a set of overloaded process() methods, with each handling a spe...
Definition: MessageProcessor.hpp:58
Connection
The connection class provides APIs that allows the application to access CEC Bus. A connection is a t...
Definition: Connection.hpp:57
Header
Definition: Header.hpp:41
Executor
Definition: Executors.h:44