A couple crasher fixes that were hiding behind the inability to

hot-restart the websocket server on the backend.
This commit is contained in:
casey langen 2017-05-29 02:28:43 -07:00
parent 2140a9bc3e
commit a42532136f
2 changed files with 16 additions and 3 deletions

View File

@ -228,7 +228,11 @@ public class StreamingPlaybackService implements PlaybackService {
if (state != PlaybackState.Paused) {
schedulePausedShutdown();
killAudioFocus();
context.currentPlayer.pause();
if (context.currentPlayer != null) {
context.currentPlayer.pause();
}
setState(PlaybackState.Paused);
}
}

View File

@ -35,6 +35,8 @@
#include "WebSocketServer.h"
#include "Constants.h"
#include <iostream>
#include <core/sdk/constants.h>
#include <boost/format.hpp>
@ -334,8 +336,15 @@ void WebSocketServer::Broadcast(const std::string& name, json& options) {
std::string str = msg.dump();
auto rl = connectionLock.Read();
for (const auto &keyValue : this->connections) {
wss->send(keyValue.first, str.c_str(), websocketpp::frame::opcode::text);
try {
if (wss) {
for (const auto &keyValue : this->connections) {
wss->send(keyValue.first, str.c_str(), websocketpp::frame::opcode::text);
}
}
}
catch (...) {
std::cerr << "broadcast failed (stale connection?)\n";
}
}