CppWAMP
C++11 client library for the WAMP protocol
chits.hpp
Go to the documentation of this file.
1 /*------------------------------------------------------------------------------
2  Copyright Butterfly Energy Systems 2022.
3  Distributed under the Boost Software License, Version 1.0.
4  http://www.boost.org/LICENSE_1_0.txt
5 ------------------------------------------------------------------------------*/
6 
7 #ifndef CPPWAMP_CHITS_HPP
8 #define CPPWAMP_CHITS_HPP
9 
10 //------------------------------------------------------------------------------
13 //------------------------------------------------------------------------------
14 
15 #include <memory>
16 #include "api.hpp"
17 #include "wampdefs.hpp"
18 #include "./internal/passkey.hpp"
19 
20 namespace wamp
21 {
22 
23 // Forward declaration
24 namespace internal { class Caller; }
25 
26 //------------------------------------------------------------------------------
28 //------------------------------------------------------------------------------
29 class CPPWAMP_API CallChit
30 {
31 public:
33  CallChit();
34 
36  explicit operator bool() const;
37 
39  RequestId requestId() const;
40 
42  CallCancelMode cancelMode() const;
43 
46  void cancel() const;
47 
49  void cancel(CallCancelMode mode) const;
50 
51 private:
52  using CallerPtr = std::weak_ptr<internal::Caller>;
53 
54  static constexpr RequestId invalidId_ = -1;
55  CallerPtr caller_;
56  RequestId reqId_ = invalidId_;
57  CallCancelMode cancelMode_ = {};
58 
59 public:
60  // Internal use only
61  CallChit(CallerPtr caller, RequestId reqId, CallCancelMode mode,
62  internal::PassKey);
63 
64 };
65 
66 } // namespace wamp
67 
68 #ifndef CPPWAMP_COMPILED_LIB
69 #include "internal/chits.ipp"
70 #endif
71 
72 #endif // CPPWAMP_CHITS_HPP
wamp::RequestId
int64_t RequestId
Ephemeral ID associated with a WAMP request.
Definition: wampdefs.hpp:23
api.hpp
Defines macros related to exporting/importing APIs.
wamp
Definition: anyhandler.hpp:36
wamp::CallChit
Lightweight token representing a call request.
Definition: chits.hpp:29
wampdefs.hpp
Contains type definitions related to WAMP IDs and sessions.
wamp::CallCancelMode
CallCancelMode
Enumerates the possible call cancelling modes.
Definition: wampdefs.hpp:49