Suppress hide/show_self until after fully connected.
parent
099a010a6e
commit
d98fd8f179
|
@ -37,6 +37,7 @@ FreeDVReporter::FreeDVReporter(std::string hostname, std::string callsign, std::
|
|||
, tx_(false)
|
||||
, rxOnly_(rxOnly)
|
||||
, hidden_(false)
|
||||
, fullyConnected_(false)
|
||||
{
|
||||
if (hostname_ == "")
|
||||
{
|
||||
|
@ -257,10 +258,12 @@ void FreeDVReporter::connect_()
|
|||
sioClient_->setOnConnectFn([&]()
|
||||
{
|
||||
isConnecting_ = false;
|
||||
fullyConnected_ = false;
|
||||
});
|
||||
|
||||
sioClient_->setOnDisconnectFn([&]() {
|
||||
isConnecting_ = false;
|
||||
fullyConnected_ = false;
|
||||
|
||||
if (onReporterDisconnectFn_)
|
||||
{
|
||||
|
@ -322,6 +325,8 @@ void FreeDVReporter::connect_()
|
|||
});
|
||||
|
||||
sioClient_->on("connection_successful", [&](nlohmann::json) {
|
||||
fullyConnected_ = true;
|
||||
|
||||
if (onConnectionSuccessfulFn_)
|
||||
{
|
||||
onConnectionSuccessfulFn_();
|
||||
|
@ -590,7 +595,14 @@ void FreeDVReporter::sendMessageImpl_(std::string message)
|
|||
|
||||
void FreeDVReporter::hideFromViewImpl_()
|
||||
{
|
||||
sioClient_->emit("hide_self");
|
||||
// The FreeDV Reporter connection isn't actually valid until we get
|
||||
// the "connection successful" message. Thus, we defer sending hide_self
|
||||
// until we get that message, but we record what state we should be
|
||||
// in the meantime.
|
||||
if (fullyConnected_)
|
||||
{
|
||||
sioClient_->emit("hide_self");
|
||||
}
|
||||
hidden_ = true;
|
||||
}
|
||||
|
||||
|
@ -601,6 +613,14 @@ void FreeDVReporter::showOurselvesImpl_()
|
|||
onAboutToShowSelfFn_();
|
||||
}
|
||||
|
||||
sioClient_->emit("show_self");
|
||||
// The FreeDV Reporter connection isn't actually valid until we get
|
||||
// the "connection successful" message. Thus, we defer sending show_self
|
||||
// until we get that message, but we record what state we should be
|
||||
// in the meantime.
|
||||
if (fullyConnected_)
|
||||
{
|
||||
sioClient_->emit("show_self");
|
||||
}
|
||||
|
||||
hidden_ = false;
|
||||
}
|
||||
|
|
|
@ -122,6 +122,7 @@ private:
|
|||
bool rxOnly_;
|
||||
bool hidden_;
|
||||
std::string message_;
|
||||
bool fullyConnected_;
|
||||
|
||||
ReporterConnectionFn onReporterConnectFn_;
|
||||
ReporterConnectionFn onReporterDisconnectFn_;
|
||||
|
|
Loading…
Reference in New Issue