3 * Copyright (c) 2020 Project CHIP Authors
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 * This file defines the classes corresponding to CHIP Exchange Context.
26 #include <system/SystemPacketBuffer.h>
27 #include <transport/raw/MessageHeader.h>
32 class ExchangeContext;
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.
41 class DLL_EXPORT ExchangeDelegate
44 virtual ~ExchangeDelegate() {}
48 * This function is the protocol callback for handling a received CHIP message.
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.
55 virtual void OnMessageReceived(ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader,
56 System::PacketBufferHandle payload) = 0;
60 * This function is the protocol callback to invoke when the timeout for the receipt
61 * of a response message has expired.
63 * @param[in] ec A pointer to the ExchangeContext object.
65 virtual void OnResponseTimeout(ExchangeContext * ec) = 0;
69 * This function is the protocol callback to invoke when the associated
70 * exchange context is being closed
72 * @param[in] ec A pointer to the ExchangeContext object.
74 virtual void OnExchangeClosing(ExchangeContext * ec) {}
77 } // namespace Messaging