Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / messaging / ExchangeDelegate.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 /**
19  *    @file
20  *      This file defines the classes corresponding to CHIP Exchange Context.
21  *
22  */
23
24 #pragma once
25
26 #include <system/SystemPacketBuffer.h>
27 #include <transport/raw/MessageHeader.h>
28
29 namespace chip {
30 namespace Messaging {
31
32 class ExchangeContext;
33
34 /**
35  * @brief
36  *   This class provides a skeleton for the callback functions. The functions will be
37  *   called by ExchangeContext object on specific events. If the user of ExchangeContext
38  *   is interested in receiving these callbacks, they can specialize this class and handle
39  *   each trigger in their implementation of this class.
40  */
41 class DLL_EXPORT ExchangeDelegate
42 {
43 public:
44     virtual ~ExchangeDelegate() {}
45
46     /**
47      * @brief
48      *   This function is the protocol callback for handling a received CHIP message.
49      *
50      *  @param[in]    ec            A pointer to the ExchangeContext object.
51      *  @param[in]    packetHeader  A reference to the PacketHeader object.
52      *  @param[in]    payloadHeader A reference to the PayloadHeader object.
53      *  @param[in]    payload       A handle to the PacketBuffer object holding the message payload.
54      */
55     virtual void OnMessageReceived(ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader,
56                                    System::PacketBufferHandle payload) = 0;
57
58     /**
59      * @brief
60      *   This function is the protocol callback to invoke when the timeout for the receipt
61      *   of a response message has expired.
62      *
63      *  @param[in]    ec            A pointer to the ExchangeContext object.
64      */
65     virtual void OnResponseTimeout(ExchangeContext * ec) = 0;
66
67     /**
68      * @brief
69      *   This function is the protocol callback to invoke when the associated
70      *   exchange context is being closed
71      *
72      *  @param[in]    ec            A pointer to the ExchangeContext object.
73      */
74     virtual void OnExchangeClosing(ExchangeContext * ec) {}
75 };
76
77 } // namespace Messaging
78 } // namespace chip