1
0
Fork 0

Remove duplicated logic in HostRoom

Fixes some issues with multiple warning messages
This commit is contained in:
James Rowe 2018-04-18 11:04:32 -06:00
parent 2be02f221d
commit a5c8e07f46
3 changed files with 7 additions and 9 deletions

View File

@ -75,13 +75,10 @@ void HostRoomWindow::Host() {
} }
if (auto member = Network::GetRoomMember().lock()) { if (auto member = Network::GetRoomMember().lock()) {
if (member->IsConnected()) { if (member->IsConnected()) {
if (!NetworkMessage::WarnDisconnect()) { auto parent = static_cast<MultiplayerState*>(parentWidget());
if (!parent->OnCloseRoom()) {
close(); close();
return; return;
} else {
member->Leave();
auto parent = static_cast<MultiplayerState*>(parentWidget());
parent->OnCloseRoom();
} }
} }
ui->host->setDisabled(true); ui->host->setDisabled(true);

View File

@ -112,9 +112,9 @@ void MultiplayerState::OnCreateRoom() {
BringWidgetToFront(host_room); BringWidgetToFront(host_room);
} }
void MultiplayerState::OnCloseRoom() { bool MultiplayerState::OnCloseRoom() {
if (!NetworkMessage::WarnCloseRoom()) if (!NetworkMessage::WarnCloseRoom())
return; return false;
if (auto room = Network::GetRoom().lock()) { if (auto room = Network::GetRoom().lock()) {
// if you are in a room, leave it // if you are in a room, leave it
if (auto member = Network::GetRoomMember().lock()) { if (auto member = Network::GetRoomMember().lock()) {
@ -123,11 +123,12 @@ void MultiplayerState::OnCloseRoom() {
// if you are hosting a room, also stop hosting // if you are hosting a room, also stop hosting
if (room->GetState() != Network::Room::State::Open) { if (room->GetState() != Network::Room::State::Open) {
return; return true;
} }
room->Destroy(); room->Destroy();
announce_multiplayer_session->Stop(); announce_multiplayer_session->Stop();
} }
return true;
} }
void MultiplayerState::OnOpenNetworkRoom() { void MultiplayerState::OnOpenNetworkRoom() {

View File

@ -42,7 +42,7 @@ public slots:
void OnNetworkStateChanged(const Network::RoomMember::State& state); void OnNetworkStateChanged(const Network::RoomMember::State& state);
void OnViewLobby(); void OnViewLobby();
void OnCreateRoom(); void OnCreateRoom();
void OnCloseRoom(); bool OnCloseRoom();
void OnOpenNetworkRoom(); void OnOpenNetworkRoom();
void OnDirectConnectToRoom(); void OnDirectConnectToRoom();
void OnAnnounceFailed(const Common::WebResult&); void OnAnnounceFailed(const Common::WebResult&);