Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class WebsocketStreamingServerImpl : public Server
explicit WebsocketStreamingServerImpl(const DevicePtr& rootDevice,
const PropertyObjectPtr& config,
const ContextPtr& context);
~WebsocketStreamingServerImpl() override;
static PropertyObjectPtr createDefaultConfig(const ContextPtr& context);
static ServerTypePtr createType(const ContextPtr& context);
static PropertyObjectPtr populateDefaultConfig(const PropertyObjectPtr& config, const ContextPtr& context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ WebsocketStreamingServerImpl::WebsocketStreamingServerImpl(const DevicePtr& root
websocketStreamingServer.start();
}

WebsocketStreamingServerImpl::~WebsocketStreamingServerImpl()
{
websocketStreamingServer.stop();
}

void WebsocketStreamingServerImpl::populateDefaultConfigFromProvider(const ContextPtr& context, const PropertyObjectPtr& config)
{
if (!context.assigned())
Expand Down
2 changes: 1 addition & 1 deletion opendaq_ref
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4757349a1db30721bead0cb695ec3a147913aef4
05d65e97c9d6f0cea5c23c423855a65426c30baf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class StreamingServer

void start(uint16_t port = daq::streaming_protocol::WEBSOCKET_LISTENING_PORT,
uint16_t controlPort = daq::streaming_protocol::HTTP_CONTROL_PORT);

void stop();
void clearCallbacks();

void onAccept(const OnAcceptCallback& callback);
void onStartSignalsRead(const OnStartSignalsReadCallback& callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class WebsocketStreamingServer
DevicePtr device;
ContextPtr context;

bool stopped = false;
uint16_t streamingPort = 0;
uint16_t controlPort = 0;
daq::websocket_streaming::StreamingServer streamingServer;
Expand Down
11 changes: 11 additions & 0 deletions shared/libraries/websocket_streaming/src/streaming_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ void StreamingServer::stop()

this->server.reset();
this->controlServer.reset();

clearCallbacks();
}

void StreamingServer::clearCallbacks()
{
onAcceptCallback = nullptr;
onStartSignalsReadCallback = nullptr;
onStopSignalsReadCallback = nullptr;
clientConnectedHandler = nullptr;
clientDisconnectedHandler = nullptr;
}

void StreamingServer::onAccept(const OnAcceptCallback& callback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ BEGIN_NAMESPACE_OPENDAQ_WEBSOCKET_STREAMING

WebsocketStreamingServer::~WebsocketStreamingServer()
{
this->context.getOnCoreEvent() -= event(this, &WebsocketStreamingServer::coreEventCallback);
stopInternal();
}

Expand Down Expand Up @@ -104,7 +103,10 @@ void WebsocketStreamingServer::start()
}

void WebsocketStreamingServer::stop()
{
{
if (stopped)
return;

if (device.assigned() && !device.isRemoved())
{
const auto info = this->device.getInfo();
Expand All @@ -124,8 +126,15 @@ void WebsocketStreamingServer::stop()

void WebsocketStreamingServer::stopInternal()
{
if (stopped)
return;

this->context.getOnCoreEvent() -= event(this, &WebsocketStreamingServer::coreEventCallback);

packetReader.stop();
streamingServer.stop();

stopped = true;
}

void WebsocketStreamingServer::coreEventCallback(ComponentPtr& sender, CoreEventArgsPtr& eventArgs)
Expand Down
Loading