25 #include <arpa/inet.h> 28 #ifndef VISIONTRANSFER_DATACHANNELSERVICEBASE_H 29 #define VISIONTRANSFER_DATACHANNELSERVICEBASE_H 49 unsigned char* payload;
65 enum DataChannelTypesEnum {
72 typedef unsigned char Type;
73 typedef unsigned char ID;
77 inline ID getChannelID()
const {
return channelID; }
78 inline std::string getInfoString()
const {
return infoString; }
79 inline void setService(std::weak_ptr<DataChannelServiceBase> serv) { service = serv; }
80 inline void setChannelID(ID
id) { channelID = id; }
82 virtual Type getChannelType()
const = 0;
86 virtual bool initialize() = 0;
88 virtual int startService() = 0;
93 virtual int stopService() = 0;
95 std::string infoString;
96 int sendData(
unsigned char* data,
unsigned int dataSize, sockaddr_in* recipient=
nullptr);
99 std::weak_ptr<DataChannelServiceBase> service;
107 inline DataChannelInfo(DataChannel::ID
id, DataChannel::Type type,
const std::string& info): channelID(
id), channelType(type), infoString(info) { }
108 inline DataChannel::ID getChannelID()
const {
return channelID; }
109 inline DataChannel::Type getChannelType()
const {
return channelType; }
110 inline std::string getInfoString()
const {
return infoString; }
112 DataChannel::ID channelID;
113 DataChannel::Type channelType;
114 std::string infoString;
127 DataChannel::ID registerChannel(std::shared_ptr<DataChannel> channel);
128 virtual int sendDataInternal(
unsigned char* compiledMessage,
unsigned int messageSize, sockaddr_in* recipient);
129 int sendDataIsolatedPacket(DataChannel::ID
id, DataChannel::Type type,
unsigned char* data,
unsigned int dataSize, sockaddr_in* recipient);
130 virtual int handleChannel0Message(
DataChannelMessage& message, sockaddr_in* sender) = 0;
132 std::map<DataChannel::ID, std::shared_ptr<DataChannel> > channels;
134 SOCKET dataChannelSocket;
136 int dataChannelSocket;
virtual bool process()
A single processing iteration; should be short and must not block. Actual frequency determined by the...
Base class all data channel services derive from (once on the server side, once on the API side) ...
Base class for the data service (background sending and receiving, dispatching to channels) ...
Known data channel service types, not all may be active on a specific device.
API-level data channel info for advertisements and subscription accounting.