• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2021 Huawei Technologies Co., Ltd
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 MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_MESSAGE_HANDLER_H_
18 #define MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_MESSAGE_HANDLER_H_
19 
20 namespace mindspore {
21 namespace ps {
22 namespace core {
23 // MessageHandler class is used to handle requests from clients and send response from server.
24 // It's the base class of HttpMsgHandler and TcpMsgHandler.
25 class MessageHandler {
26  public:
27   MessageHandler() = default;
28   virtual ~MessageHandler() = default;
29 
30   // Raw data of this message in bytes.
31   virtual void *data() const = 0;
32 
33   // Raw data size of this message.(Number of bytes)
34   virtual size_t len() const = 0;
35 
36   virtual bool SendResponse(const void *data, const size_t &len) = 0;
37 };
38 }  // namespace core
39 }  // namespace ps
40 }  // namespace mindspore
41 #endif  // MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_MESSAGE_HANDLER_H_
42