Listens for incoming messages and manages queue of outgoing messages. More...

#include <Server.h>

Inheritance diagram for SSDP::Server:
Collaboration diagram for SSDP::Server:

Public Member Functions

 Server ()
 
bool begin (ReceiveDelegate receiveCallback, SendDelegate sendCallback)
 Called from UPnP library to start SSDP server. More...
 
void end ()
 Stop SSDP server. More...
 
bool isActive ()
 Determine if server is running. More...
 
bool sendMessage (const Message &msg)
 Send a message immediately. More...
 
bool buildMessage (Message &msg, MessageSpec &ms)
 Construct a message from the given template spec. More...
 
void setProduct (const String &name, const String &version)
 Set product name and version contained in SSDP message USER-AGENT field. More...
 

Public Attributes

MessageQueue messageQueue
 

Static Public Attributes

static constexpr uint8_t multicastTtl {2}
 

Protected Member Functions

void onReceive (pbuf *buf, IpAddress remoteIP, uint16_t remotePort) override
 

Detailed Description

Listens for incoming messages and manages queue of outgoing messages.

Note
The spec. talks about random intervals, etc. but to keep things simple we just use a timer to spread all these messages out at regular intervals.
Todo:
Randomise the time as required by MX and keep queue ordered by time. Each message is 12 bytes, adding time would make this 16. Need to handle alives < 1/2 expiry time as well so timer will always be active. Could also use a linked list so an additional pointer would make it 20 bytes.

Note: This is basically another timer queue, so we could use software timers directly but potentially there could be a lot of them. Better I think to use a single Timer and drive it from that.

Constructor & Destructor Documentation

◆ Server()

SSDP::Server::Server ( )
inline

Member Function Documentation

◆ begin()

bool SSDP::Server::begin ( ReceiveDelegate  receiveCallback,
SendDelegate  sendCallback 
)

Called from UPnP library to start SSDP server.

Note
May only be called once
Return values
booltrue on success

◆ buildMessage()

bool SSDP::Server::buildMessage ( Message msg,
MessageSpec ms 
)

Construct a message from the given template spec.

Parameters
msgFields of this message will be filled out
msSpec to use for constructing message
Return values
boolReturns false if validation failed: message should not be sent

◆ end()

void SSDP::Server::end ( )

Stop SSDP server.

◆ isActive()

bool SSDP::Server::isActive ( )
inline

Determine if server is running.

Return values
bool

◆ onReceive()

void SSDP::Server::onReceive ( pbuf *  buf,
IpAddress  remoteIP,
uint16_t  remotePort 
)
overrideprotectedvirtual

Reimplemented from UdpConnection.

◆ sendMessage()

bool SSDP::Server::sendMessage ( const Message msg)

Send a message immediately.

◆ setProduct()

void SSDP::Server::setProduct ( const String name,
const String version 
)
inline

Set product name and version contained in SSDP message USER-AGENT field.

Member Data Documentation

◆ messageQueue

MessageQueue SSDP::Server::messageQueue

◆ multicastTtl

constexpr uint8_t SSDP::Server::multicastTtl {2}
staticconstexpr

The documentation for this class was generated from the following file: