13 #ifndef __BAOSLIB_EVENT_H__
14 #define __BAOSLIB_EVENT_H__
16 #include "baos/BaosLib_export.h"
20 #include "wzcpp/features/concurrent/concurrent_queue.h"
44 using UPtr = std::unique_ptr<IOEvent>;
45 using EventDataType = std::variant<ip::Ip4SocketAddress, std::unique_ptr<Buffer>>;
73 responsePromise{std::move(prom)}
75 data_ = std::move(pkt);
79 Type eventType{Type::UNKNOWN};
80 std::uint64_t msgID{0};
82 bool promiseMoved{
false};
103 return "SOCKETERROR";
105 return "RESPONSETIMEOUT";
113 return "Unhandled IOEvent type";
Provides the structures for devices with IP capabilities.
Classes regarding response telegrams.
Represents an IOEvent.
Definition: IOEvent.h:42
std::unique_ptr< IOEvent > UPtr
An alias for an unique pointer to an IOEvent.
Definition: IOEvent.h:44
Type
The different possible event types.
Definition: IOEvent.h:50
@ HEARTBEAT
A Heartbeat is requested.
@ RESPONSETIMEOUT
The response was not received in the through timeout given period.
@ TX_PACKET
An outgoing (TX) packet should be handled.
@ UNKNOWN
If event is not specified.
@ CLOSE
An close event is requested.
@ SOCKETERROR
Errors regarding the underlying socket.
@ OPEN
An open event is requested.
@ RX_PACKET
An incoming (RX) packet was received and should be handled.
EventDataType data_
The payload/data for this event.
Definition: IOEvent.h:83
IOEvent(Type eventT, EventDataType &&pkt, protocol::ResponsePromise &&prom, std::uint64_t mID=0)
Construct a new IOEvent object.
Definition: IOEvent.h:70
IOEvent()=default
Default constructor, generating an empty IOEvent.
std::variant< ip::Ip4SocketAddress, std::unique_ptr< Buffer > > EventDataType
Definition: IOEvent.h:46
protocol::ResponsePromise responsePromise
Stores the response promise to resolve later.
Definition: IOEvent.h:81
Global types and configuration for the whole SDK.
std::promise< BaseResponse::SPtr > ResponsePromise
Definition: Response.h:95
Global BAOS sdk namespace.
Definition: config.h:62
std::string toString(IOEvent::Type typ)
Provides a human readable string for an IOEvent type.
Definition: IOEvent.h:92
wzcpp::ConcurrentDeque< IOEvent > BaosMsgQueue
Alias for a concurrent queue with IOEvents.
Definition: IOEvent.h:117