Ocean
Loading...
Searching...
No Matches
StreamingServer.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef FACEBOOK_NETWORK_STREAMING_SERVER_H
9#define FACEBOOK_NETWORK_STREAMING_SERVER_H
10
12#include "ocean/network/Port.h"
16
17#include "ocean/base/Callback.h"
18#include "ocean/base/Lock.h"
19
20namespace Ocean
21{
22
23namespace Network
24{
25
26/**
27 * This class implements a streaming server.
28 * @ingroup network
29 */
30class OCEAN_NETWORK_EXPORT StreamingServer : public Streaming
31{
32 public:
33
34 /**
35 * Definition of a callback function on channel start, stop or pause requests.
36 */
38
39 /**
40 * Definition of a channel id.
41 */
42 using ChannelId = unsigned int;
43
44 /**
45 * Returns an invalid channel id.
46 * @return Invalid channel id
47 */
48 static constexpr ChannelId invalidChannelId();
49
50 protected:
51
52 /**
53 * This class implements a channel.
54 */
55 class Channel
56 {
57 public:
58
59 /**
60 * Definition of a stream id.
61 */
62 using StreamId = unsigned int;
63
64 /**
65 * Returns an invalid stream id.
66 * @return Invalid stream id
67 */
68 static constexpr StreamId invalidStreamId();
69
70 public:
71
72 /**
73 * This class implements a stream.
74 */
75 class Stream
76 {
77 public:
78
79 /**
80 * Creates a new stream object.<br>
81 * A stream is in stopped mode by default.
82 * @param tcpConnectionId The id of the TCP configuration
83 * @param receiverAddress Address4 of the stream receiver
84 * @param receiverPort Port of the stream receiver
85 */
86 Stream(const TCPServer::ConnectionId tcpConnectionId, const Address4& receiverAddress, const Port& receiverPort);
87
88 /**
89 * (Re-)Starts the stream.
90 * @return True, if succeeded
91 */
92 bool start();
93
94 /**
95 * Pauses the stream.
96 * @return True, if succeeded
97 */
98 bool pause();
99
100 /**
101 * Returns whether this stream is currently streaming.
102 * @return True, if so
103 */
104 inline bool isStreaming() const;
105
106 /**
107 * Returns the id of the TCP configuration connection associated with this stream.
108 * @return Configuration connection
109 */
110 inline TCPServer::ConnectionId tcpConnectionId() const;
111
112 /**
113 * Returns the address of the used sender UDP client.
114 * @return Sender address
115 */
116 inline Address4 senderAddress() const;
117
118 /**
119 * Returns the port the used sender UDP client.
120 * @return Sender port
121 */
122 inline Port senderPort() const;
123
124 /**
125 * Returns the address of the receiver.
126 * @return Receiver address
127 */
128 inline const Address4& receiverAddress() const;
129
130 /**
131 * Returns the port of the receiver.
132 * @return Receiver port
133 */
134 inline const Port& receiverPort() const;
135
136 /**
137 * Streams new data using the given UDP connections.
138 * @param data The data to stream
139 * @param size The size of the data to stream in bytes
140 * @return True, if succeeded
141 */
142 bool stream(const void* data, const size_t size);
143
144 protected:
145
146 /**
147 * Disabled copy constructor.
148 * @param stream Object which would be copied
149 */
150 Stream(const Stream& stream) = delete;
151
152 /**
153 * Disabled copy operator.
154 * @param stream Object which would be copied
155 * @return Reference to this object
156 */
157 Stream& operator=(const Stream& stream) = delete;
158
159 protected:
160
161 /// The id of the TCP configuration connection.
162 TCPServer::ConnectionId tcpConnectionId_ = TCPServer::invalidConnectionId();
163
164 /// UDP client used for stream data transfer.
166
167 /// Stream receiver address.
169
170 /// Stream receiver port.
172
173 /// Determines whether data should be streamed.
174 bool isStreaming_ = false;
175 };
176
177 /**
178 * Definition of a map mapping stream ids to streams.
179 */
180 using StreamMap = std::map<StreamId, std::shared_ptr<Stream>>;
181
182 public:
183
184 /**
185 * Creates a new default channel.
186 */
187 Channel() = default;
188
189 /**
190 * Creates a new channel.
191 * @param name Unique channel name
192 * @param dataType Data type of the channel
193 * @param callback Channel callback function.
194 */
195 Channel(const std::string& name, const std::string& dataType, const ChannelCallback& callback);
196
197 /**
198 * Adds a new stream to this channel.
199 * @param tcpConnectionId The id of the TCP configuration connection
200 * @param address Address4 of the stream receiver
201 * @param port Port of the stream receiver
202 * @return A valid stream id, if succeeded
203 */
204 StreamId addStream(const TCPServer::ConnectionId tcpConnectionId, const Address4& address, const Port& port);
205
206 /**
207 * Removes a stream from this channel.
208 * @param streamId Id of the stream to remove
209 * @return True, if the stream existed
210 */
211 bool removeStream(const StreamId streamId);
212
213 /**
214 * (Re-)starts a stream of this channel.
215 * @param streamId Id of the stream to start
216 * @return True, if succeeded
217 */
218 bool startStream(const StreamId streamId);
219
220 /**
221 * Pauses a stream.
222 * @param streamId Id of the stream to pause
223 * @return True, if succeeded
224 */
225 bool pauseStream(const StreamId streamId);
226
227 /**
228 * Stops and removes a stream of this channel.
229 * @param streamId Id of the stream to stop
230 * @return True, if succeeded
231 */
232 bool stopStream(const StreamId streamId);
233
234 /**
235 * Returns the name of this channel.
236 * @return Unique channel name
237 */
238 inline const std::string& name() const;
239
240 /**
241 * Returns the data type of this channel.
242 * @return Channel data type
243 */
244 inline const std::string& dataType() const;
245
246 /**
247 * Returns the UDP client sender port of a given stream.
248 * @param streamId Id of the stream to return the UDP sender port for
249 * @return UDP server sender port
250 */
251 Port streamSenderPort(const StreamId streamId) const;
252
253 /**
254 * Sets or changes the data type of this channel.
255 * @param configurationTCPServer TCP server of the streaming server used for stream configurations
256 * @param messageQueue Message queue of the streaming server used for message identification
257 * @param dataType New data type to set
258 * @return True, if succeeded
259 */
260 bool setDataType(TCPServer& configurationTCPServer, MessageQueue& messageQueue, const std::string& dataType);
261
262 /**
263 * Streams new data using the given UDP connections.
264 * @param data Data to stream
265 * @param size Size of the data to stream in bytes
266 * @return True, if succeeded
267 */
268 bool stream(const void* data, const size_t size);
269
270 protected:
271
272 /// Unique Channel name.
273 std::string name_;
274
275 /// Data type of the channel.
276 std::string dataType_;
277
278 /// Determines the number of active streaming streams.
279 unsigned int activeStreams_ = 0u;
280
281 /// Streams used for this channel.
283
284 /// Stream id counter.
285 StreamId streamIdCounter_ = StreamId(0);
286
287 /// Channel request callback function.
289 };
290
291 /**
292 * Definition of a map mapping channel ids to channels.
293 */
294 using ChannelMap = std::map<ChannelId, Channel>;
295
296 /**
297 * This class holds some information connected with a TCP connection.
298 * @ingroup network
299 */
301 {
302 public:
303
304 /**
305 * Creates an empty connection object.
306 */
307 inline Connection() = default;
308
309 /**
310 * Creates a new connection object.
311 * @param receiver The receiver address of the stream data
312 */
313 inline Connection(const Address4& receiver);
314
315 /**
316 * Returns the channel id.
317 * @return Channel id
318 */
319 inline ChannelId channelId() const;
320
321 /**
322 * Returns the stream id inside the channel.
323 * @return Channel stream id
324 */
325 inline Channel::StreamId channelStreamId() const;
326
327 /**
328 * Returns the stream receiver address of this connection.
329 * @return Receiver address
330 */
331 inline const Address4& address() const;
332
333 /**
334 * Returns the stream receiver port of this connection.
335 * @return Receiver port
336 */
337 inline const Port& port() const;
338
339 /**
340 * Sets the channel id of this connection.
341 * @param channelId Channel id to set
342 * @return True, if succeeded
343 */
344 inline bool setChannelId(const ChannelId channelId);
345
346 /**
347 * Sets the channel stream id of this connection.
348 * @param streamId Stream id to set
349 * @return True, if succeeded
350 */
351 inline bool setChannelStreamId(const Channel::StreamId streamId);
352
353 /**
354 * Sets the port of the stream data.
355 * @param port Port to set
356 * @return True, if succeeded
357 */
358 inline bool setPort(const Port& port);
359
360 private:
361
362 /// Id of the channel.
363 ChannelId channelId_ = invalidChannelId();
364
365 /// Id of the stream.
366 Channel::StreamId channelStreamId_ = Channel::invalidStreamId();
367
368 /// Receiver address of the streaming data.
370
371 /// Receiver port of the streaming data.
373 };
374
375 /**
376 * Definition of a map mapping TCP connection ids to server stream connections.
377 */
378 using ConnectionMap = std::unordered_map<TCPServer::ConnectionId, Connection>;
379
380 public:
381
382 /**
383 * Creates a new streaming server.
384 */
386
387 /**
388 * Destructs a streaming server.
389 */
391
392 /**
393 * Sets the server address.
394 * If the systems supports more than one network address use this function to define which address to use for this server.<br>
395 * However, normally is not necessary to define the local address.
396 * @param address Address to use for this streaming server
397 * @return True, if succeeded
398 */
399 bool setAddress(const Address4& address);
400
401 /**
402 * Sets the server port.
403 * @param port Server port to set
404 * @return True, if succeeded
405 */
406 bool setPort(const Port& port);
407
408 /**
409 * Returns the server address.
410 * @return Server address
411 */
413
414 /**
415 * Returns the server port.
416 * @return Server port
417 */
418 Port port() const;
419
420 /**
421 * Enables the streaming server.
422 * @return True, if succeeded
423 */
424 bool enable();
425
426 /**
427 * Disables the streaming server.
428 * @return True, if succeeded
429 */
430 bool disable();
431
432 /**
433 * Returns whether the server is enabled.
434 * @return True, if so
435 */
436 inline bool isEnabled() const;
437
438 /**
439 * Registers a new channel.
440 * @param channel Unique name of the new channel to register
441 * @param dataType Data type provides by the channel
442 * @param callback Channel request callback
443 * @return Valid channel id if succeeded
444 */
445 ChannelId registerChannel(const std::string& channel, const std::string& dataType, const ChannelCallback& callback);
446
447 /**
448 * Changes the data type of a channel.
449 * @param channelId SessionId of the channel to change the data type for
450 * @param dataType New data type to set
451 * @return True, if succeeded
452 */
453 bool changeDataType(const ChannelId channelId, const std::string& dataType);
454
455 /**
456 * Unregister a channel.
457 * @param channelId SessionId of the channel to unregister
458 * @return True, if succeeded
459 */
460 bool unregisterChannel(const ChannelId channelId);
461
462 /**
463 * Returns whether this server holds a specified channel.
464 * @return True, if the channel exists already
465 */
466 bool hasChannel(const std::string& channel) const;
467
468 /**
469 * Releases all channels.
470 */
471 void release();
472
473 /**
474 * Sets new streaming data for a specified channel.
475 * @param channelId SessionId of the streaming channel
476 * @param data Streaming data
477 * @param size Streaming data size in bytes
478 * @return True, if the data was accepted
479 */
480 bool stream(const ChannelId channelId, const void* data, const size_t size);
481
482 /**
483 * Returns the number of registered channels.
484 * @return Channels
485 */
486 inline size_t channels() const;
487
488 /**
489 * Returns a generated but unique channel name.
490 * @return Unique channel name
491 */
492 std::string generateUniqueChannel() const;
493
494 protected:
495
496 /**
497 * New TCP connection request function.
498 * @param address Sender address
499 * @param port Sender port
500 * @param connectionId TCP server specific connection id
501 */
502 bool onTCPConnection(const Address4& address, const Port& port, const TCPServer::ConnectionId connectionId);
503
504 /**
505 * Callback function for TCP disconnect.
506 * @param tcpConnectionId TCP server connection id that was disconnected
507 */
508 void onTCPDisconnect(const TCPServer::ConnectionId tcpConnectionId);
509
510 /**
511 * New command function.
512 * @param tcpConnectionId TCP server connection id
513 * @param command New command to handle
514 * @param value Command value
515 * @param sessionId Unique id of the server which is not unique on the client side
516 */
517 void onCommand(const TCPServer::ConnectionId tcpConnectionId, const std::string& command, const std::string& value, const SessionId sessionId);
518
519 /**
520 * Function handling connect commands.
521 * @param tcpConnectionId TCP server connection id
522 * @param value Command value
523 * @param sessionId Unique id of the server which is not unique on the client side
524 */
525 void onConnect(const TCPServer::ConnectionId tcpConnectionId, const std::string& value, const SessionId sessionId);
526
527 /**
528 * Function handling disconnect commands.
529 * @param tcpConnectionId TCP server connection id
530 * @param value Command value
531 * @param sessionId Unique id of the server which is not unique on the client side
532 */
533 void onDisconnect(const TCPServer::ConnectionId tcpConnectionId, const std::string& value, const SessionId sessionId);
534
535 /**
536 * Function handling client port commands.
537 * @param tcpConnectionId TCP server connection id
538 * @param value Command value
539 * @param sessionId Unique id of the server which is not unique on the client side
540 */
541 void onClientPort(const TCPServer::ConnectionId tcpConnectionId, const std::string& value, const SessionId sessionId);
542
543 /**
544 * Function handling server port commands.
545 * @param tcpConnectionId TCP server connection id
546 * @param value Command value
547 * @param sessionId Unique id of the server which is not unique on the client side
548 */
549 void onServerPort(const TCPServer::ConnectionId tcpConnectionId, const std::string& value, const SessionId sessionId);
550
551 /**
552 * Function handling channel select commands.
553 * @param tcpConnectionId TCP server connection id
554 * @param value Command value
555 * @param sessionId Unique id of the server which is not unique on the client side
556 */
557 void onChannelSelect(const TCPServer::ConnectionId tcpConnectionId, const std::string& value, const SessionId sessionId);
558
559 /**
560 * Function handling start commands.
561 * @param tcpConnectionId TCP server connection id
562 * @param value Command value
563 * @param sessionId Unique id of the server which is not unique on the client side
564 */
565 void onStart(const TCPServer::ConnectionId tcpConnectionId, const std::string& value, const SessionId sessionId);
566
567 /**
568 * Function handling pause commands.
569 * @param tcpConnectionId TCP server connection id
570 * @param value Command value
571 * @param sessionId Unique id of the server which is not unique on the client side
572 */
573 void onPause(const TCPServer::ConnectionId tcpConnectionId, const std::string& value, const SessionId sessionId);
574
575 /**
576 * Function handling stop commands.
577 * @param tcpConnectionId TCP server connection id
578 * @param value Command value
579 * @param sessionId Unique id of the server which is not unique on the client side
580 */
581 void onStop(const TCPServer::ConnectionId tcpConnectionId, const std::string& value, const SessionId sessionId);
582
583 /**
584 * Function handling channel commands.
585 * @param tcpConnectionId TCP server connection id
586 * @param value Command value
587 * @param sessionId Unique id of the server which is not unique on the client side
588 */
589 void onChannelRequest(const TCPServer::ConnectionId tcpConnectionId, const std::string& value, const SessionId sessionId);
590
591 /**
592 * Function handling data type commands.
593 * @param tcpConnectionId TCP server connection id
594 * @param value Command value
595 * @param sessionId Unique id of the server which is not unique on the client side
596 */
597 void onDataTypeRequest(const TCPServer::ConnectionId tcpConnectionId, const std::string& value, const SessionId sessionId);
598
599 /**
600 * Callback function for TCP receive message.
601 * @param tcpConnectionId TCP server connection id
602 * @param data Received data
603 * @param size The size of the received data
604 */
605 void onTCPReceive(const TCPServer::ConnectionId tcpConnectionId, const void* data, const size_t size);
606
607 protected:
608
609 /// Determines whether the server is enabled.
610 bool isEnabled_ = false;
611
612 /// TCP server used for configuration tasks.
614
615 /// Registered channels.
617
618 /// Channel id counter.
619 ChannelId channelIdCounter_ = ChannelId(0);
620
621 /// Map mapping TCP connection ids to subscribed channels.
623
624 /// Server lock.
625 mutable Lock lock_;
626};
627
632
637
639{
640 return isStreaming_;
641}
642
644{
645 return tcpConnectionId_;
646}
647
649{
650 return udpClient_.address();
651}
652
654{
655 return udpClient_.port();
656}
657
659{
660 return address_;
661}
662
664{
665 return port_;
666}
667
668inline const std::string& StreamingServer::Channel::name() const
669{
670 return name_;
671}
672
673inline const std::string& StreamingServer::Channel::dataType() const
674{
675 return dataType_;
676}
677
679 address_(receiver)
680{
681 // nothing to do here
682}
683
685{
686 return channelId_;
687}
688
690{
691 return channelStreamId_;
692}
693
695{
696 return address_;
697}
698
700{
701 return port_;
702}
703
705{
706 if (channelId_ != invalidChannelId())
707 {
708 return false;
709 }
710
711 channelId_ = channelId;
712 return true;
713}
714
716{
717 if (channelStreamId_ != Channel::invalidStreamId())
718 {
719 return false;
720 }
721
722 channelStreamId_ = streamId;
723 return true;
724}
725
727{
728 if (port_.isNull() == false || port.isNull())
729 {
730 return false;
731 }
732
733 port_ = port;
734 return true;
735}
736
737inline bool StreamingServer::isEnabled() const
738{
739 return isEnabled_;
740}
741
742inline size_t StreamingServer::channels() const
743{
744 const ScopedLock scopedLock(lock_);
745
746 return channelMap_.size();
747}
748
749}
750
751}
752
753#endif // FACEBOOK_NETWORK_STREAMING_SERVER_H
This class implements a recursive lock object.
Definition Lock.h:31
This class wraps an address number with 32 bits.
Definition Address4.h:26
unsigned int ConnectionId
Definition of a connection id.
Definition ConnectionOrientedServer.h:34
This class implements a message queue.
Definition MessageQueue.h:28
This class implements a UDP client able to send larger messages as normally restricted by the UDP pro...
Definition PackagedUDPClient.h:25
This class wraps a port number with 16 bits.
Definition Port.h:26
bool isNull() const
Returns whether this port holds a zero value.
Definition Port.h:136
This class is the base class for all streaming objects.
Definition Streaming.h:25
MessageQueue::Id SessionId
Definition of a session id.
Definition Streaming.h:46
std::string name_
Name of this streaming object.
Definition Streaming.h:241
This class implements a stream.
Definition StreamingServer.h:76
Stream(const Stream &stream)=delete
Disabled copy constructor.
bool stream(const void *data, const size_t size)
Streams new data using the given UDP connections.
Port port_
Stream receiver port.
Definition StreamingServer.h:171
Port senderPort() const
Returns the port the used sender UDP client.
Definition StreamingServer.h:653
bool isStreaming() const
Returns whether this stream is currently streaming.
Definition StreamingServer.h:638
const Address4 & receiverAddress() const
Returns the address of the receiver.
Definition StreamingServer.h:658
const Port & receiverPort() const
Returns the port of the receiver.
Definition StreamingServer.h:663
TCPServer::ConnectionId tcpConnectionId() const
Returns the id of the TCP configuration connection associated with this stream.
Definition StreamingServer.h:643
Stream & operator=(const Stream &stream)=delete
Disabled copy operator.
Address4 address_
Stream receiver address.
Definition StreamingServer.h:168
Stream(const TCPServer::ConnectionId tcpConnectionId, const Address4 &receiverAddress, const Port &receiverPort)
Creates a new stream object.
Address4 senderAddress() const
Returns the address of the used sender UDP client.
Definition StreamingServer.h:648
PackagedUDPClient udpClient_
UDP client used for stream data transfer.
Definition StreamingServer.h:165
This class implements a channel.
Definition StreamingServer.h:56
Channel()=default
Creates a new default channel.
StreamId addStream(const TCPServer::ConnectionId tcpConnectionId, const Address4 &address, const Port &port)
Adds a new stream to this channel.
bool startStream(const StreamId streamId)
(Re-)starts a stream of this channel.
bool removeStream(const StreamId streamId)
Removes a stream from this channel.
bool stream(const void *data, const size_t size)
Streams new data using the given UDP connections.
const std::string & dataType() const
Returns the data type of this channel.
Definition StreamingServer.h:673
std::map< StreamId, std::shared_ptr< Stream > > StreamMap
Definition of a map mapping stream ids to streams.
Definition StreamingServer.h:180
unsigned int StreamId
Definition of a stream id.
Definition StreamingServer.h:62
ChannelCallback channelCallback_
Channel request callback function.
Definition StreamingServer.h:288
static constexpr StreamId invalidStreamId()
Returns an invalid stream id.
Definition StreamingServer.h:633
std::string name_
Unique Channel name.
Definition StreamingServer.h:273
Channel(const std::string &name, const std::string &dataType, const ChannelCallback &callback)
Creates a new channel.
bool pauseStream(const StreamId streamId)
Pauses a stream.
const std::string & name() const
Returns the name of this channel.
Definition StreamingServer.h:668
bool stopStream(const StreamId streamId)
Stops and removes a stream of this channel.
StreamMap streamMap_
Streams used for this channel.
Definition StreamingServer.h:282
Port streamSenderPort(const StreamId streamId) const
Returns the UDP client sender port of a given stream.
std::string dataType_
Data type of the channel.
Definition StreamingServer.h:276
bool setDataType(TCPServer &configurationTCPServer, MessageQueue &messageQueue, const std::string &dataType)
Sets or changes the data type of this channel.
This class holds some information connected with a TCP connection.
Definition StreamingServer.h:301
ChannelId channelId() const
Returns the channel id.
Definition StreamingServer.h:684
bool setPort(const Port &port)
Sets the port of the stream data.
Definition StreamingServer.h:726
bool setChannelStreamId(const Channel::StreamId streamId)
Sets the channel stream id of this connection.
Definition StreamingServer.h:715
Address4 address_
Receiver address of the streaming data.
Definition StreamingServer.h:369
Connection()=default
Creates an empty connection object.
Port port_
Receiver port of the streaming data.
Definition StreamingServer.h:372
const Port & port() const
Returns the stream receiver port of this connection.
Definition StreamingServer.h:699
Channel::StreamId channelStreamId() const
Returns the stream id inside the channel.
Definition StreamingServer.h:689
bool setChannelId(const ChannelId channelId)
Sets the channel id of this connection.
Definition StreamingServer.h:704
const Address4 & address() const
Returns the stream receiver address of this connection.
Definition StreamingServer.h:694
This class implements a streaming server.
Definition StreamingServer.h:31
static constexpr ChannelId invalidChannelId()
Returns an invalid channel id.
Definition StreamingServer.h:628
bool disable()
Disables the streaming server.
void onClientPort(const TCPServer::ConnectionId tcpConnectionId, const std::string &value, const SessionId sessionId)
Function handling client port commands.
ChannelId registerChannel(const std::string &channel, const std::string &dataType, const ChannelCallback &callback)
Registers a new channel.
void onTCPReceive(const TCPServer::ConnectionId tcpConnectionId, const void *data, const size_t size)
Callback function for TCP receive message.
void onStart(const TCPServer::ConnectionId tcpConnectionId, const std::string &value, const SessionId sessionId)
Function handling start commands.
bool setPort(const Port &port)
Sets the server port.
Lock lock_
Server lock.
Definition StreamingServer.h:625
TCPServer tcpServer_
TCP server used for configuration tasks.
Definition StreamingServer.h:613
ConnectionMap connectionMap_
Map mapping TCP connection ids to subscribed channels.
Definition StreamingServer.h:622
void release()
Releases all channels.
~StreamingServer() override
Destructs a streaming server.
void onCommand(const TCPServer::ConnectionId tcpConnectionId, const std::string &command, const std::string &value, const SessionId sessionId)
New command function.
void onConnect(const TCPServer::ConnectionId tcpConnectionId, const std::string &value, const SessionId sessionId)
Function handling connect commands.
ChannelMap channelMap_
Registered channels.
Definition StreamingServer.h:616
void onChannelRequest(const TCPServer::ConnectionId tcpConnectionId, const std::string &value, const SessionId sessionId)
Function handling channel commands.
bool isEnabled_
Determines whether the server is enabled.
Definition StreamingServer.h:610
Port port() const
Returns the server port.
void onServerPort(const TCPServer::ConnectionId tcpConnectionId, const std::string &value, const SessionId sessionId)
Function handling server port commands.
bool hasChannel(const std::string &channel) const
Returns whether this server holds a specified channel.
bool setAddress(const Address4 &address)
Sets the server address.
bool stream(const ChannelId channelId, const void *data, const size_t size)
Sets new streaming data for a specified channel.
unsigned int ChannelId
Definition of a channel id.
Definition StreamingServer.h:42
std::string generateUniqueChannel() const
Returns a generated but unique channel name.
void onTCPDisconnect(const TCPServer::ConnectionId tcpConnectionId)
Callback function for TCP disconnect.
bool unregisterChannel(const ChannelId channelId)
Unregister a channel.
void onDataTypeRequest(const TCPServer::ConnectionId tcpConnectionId, const std::string &value, const SessionId sessionId)
Function handling data type commands.
Address4 address() const
Returns the server address.
StreamingServer()
Creates a new streaming server.
void onStop(const TCPServer::ConnectionId tcpConnectionId, const std::string &value, const SessionId sessionId)
Function handling stop commands.
bool isEnabled() const
Returns whether the server is enabled.
Definition StreamingServer.h:737
bool enable()
Enables the streaming server.
std::unordered_map< TCPServer::ConnectionId, Connection > ConnectionMap
Definition of a map mapping TCP connection ids to server stream connections.
Definition StreamingServer.h:378
void onDisconnect(const TCPServer::ConnectionId tcpConnectionId, const std::string &value, const SessionId sessionId)
Function handling disconnect commands.
void onChannelSelect(const TCPServer::ConnectionId tcpConnectionId, const std::string &value, const SessionId sessionId)
Function handling channel select commands.
bool changeDataType(const ChannelId channelId, const std::string &dataType)
Changes the data type of a channel.
size_t channels() const
Returns the number of registered channels.
Definition StreamingServer.h:742
std::map< ChannelId, Channel > ChannelMap
Definition of a map mapping channel ids to channels.
Definition StreamingServer.h:294
bool onTCPConnection(const Address4 &address, const Port &port, const TCPServer::ConnectionId connectionId)
New TCP connection request function.
void onPause(const TCPServer::ConnectionId tcpConnectionId, const std::string &value, const SessionId sessionId)
Function handling pause commands.
This class implements a TCP server.
Definition TCPServer.h:25
This class implements a scoped lock object for recursive lock objects.
Definition Lock.h:147
The namespace covering the entire Ocean framework.
Definition Accessor.h:15