Line data Source code
1 : /*
2 : * Copyright (c) 2023 Project CHIP Authors
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 : #pragma once
18 :
19 : #include <transport/Session.h>
20 : #include <transport/raw/MessageHeader.h>
21 :
22 : namespace chip {
23 :
24 : namespace Transport {
25 : class ActiveTCPConnectionHolder;
26 : struct ActiveTCPConnectionState;
27 : } // namespace Transport
28 :
29 : /**
30 : * @brief
31 : * This class defines a delegate that will be called by the SessionManager on
32 : * specific connection-related (e.g. for TCP) events. If the user of SessionManager
33 : * is interested in receiving these callbacks, they can specialize this class and
34 : * handle each trigger in their implementation of this class.
35 : */
36 : class DLL_EXPORT SessionConnectionDelegate
37 : {
38 : public:
39 454 : virtual ~SessionConnectionDelegate() {}
40 :
41 : /**
42 : * @brief
43 : * Called when the underlying TCP connection for the session is closed.
44 : *
45 : * @param conn The TCP connection state
46 : * @param session The handle to the secure session
47 : * @param conErr The connection error code
48 : */
49 : virtual void OnTCPConnectionClosed(const Transport::ActiveTCPConnectionState & conn, const SessionHandle & session,
50 : CHIP_ERROR conErr) = 0;
51 :
52 : /**
53 : * @brief
54 : * Called when the underlying TCP connection attempt for the session is complete. Returns true if handled.
55 : *
56 : * @param conn The TCP connection state
57 : * @param conErr The connection error code if the connection was unsuccessful
58 : */
59 : virtual bool OnTCPConnectionAttemptComplete(Transport::ActiveTCPConnectionHolder & conn, CHIP_ERROR conErr) = 0;
60 : };
61 :
62 : } // namespace chip
|