mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-14 05:55:13 +01:00
citra: add errors callback and add status message types
This commit is contained in:
parent
bd29f1facb
commit
6feeaed77e
@ -81,42 +81,53 @@ static void OnStateChanged(const Network::RoomMember::State& state) {
|
|||||||
case Network::RoomMember::State::Joined:
|
case Network::RoomMember::State::Joined:
|
||||||
LOG_DEBUG(Network, "Successfully joined to the room");
|
LOG_DEBUG(Network, "Successfully joined to the room");
|
||||||
break;
|
break;
|
||||||
case Network::RoomMember::State::LostConnection:
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnNetworkError(const Network::RoomMember::Error& error) {
|
||||||
|
switch (error) {
|
||||||
|
case Network::RoomMember::Error::LostConnection:
|
||||||
LOG_DEBUG(Network, "Lost connection to the room");
|
LOG_DEBUG(Network, "Lost connection to the room");
|
||||||
break;
|
break;
|
||||||
case Network::RoomMember::State::CouldNotConnect:
|
case Network::RoomMember::Error::CouldNotConnect:
|
||||||
LOG_ERROR(Network, "State: CouldNotConnect");
|
LOG_ERROR(Network, "Error: Could not connect");
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
case Network::RoomMember::State::NameCollision:
|
case Network::RoomMember::Error::NameCollision:
|
||||||
LOG_ERROR(
|
LOG_ERROR(
|
||||||
Network,
|
Network,
|
||||||
"You tried to use the same nickname as another user that is connected to the Room");
|
"You tried to use the same nickname as another user that is connected to the Room");
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
case Network::RoomMember::State::MacCollision:
|
case Network::RoomMember::Error::MacCollision:
|
||||||
LOG_ERROR(Network, "You tried to use the same MAC-Address as another user that is "
|
LOG_ERROR(Network, "You tried to use the same MAC-Address as another user that is "
|
||||||
"connected to the Room");
|
"connected to the Room");
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
case Network::RoomMember::State::ConsoleIdCollision:
|
case Network::RoomMember::Error::ConsoleIdCollision:
|
||||||
LOG_ERROR(Network, "Your Console ID conflicted with someone else in the Room");
|
LOG_ERROR(Network, "Your Console ID conflicted with someone else in the Room");
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
case Network::RoomMember::State::WrongPassword:
|
case Network::RoomMember::Error::WrongPassword:
|
||||||
LOG_ERROR(Network, "Room replied with: Wrong password");
|
LOG_ERROR(Network, "Room replied with: Wrong password");
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
case Network::RoomMember::State::WrongVersion:
|
case Network::RoomMember::Error::WrongVersion:
|
||||||
LOG_ERROR(Network,
|
LOG_ERROR(Network,
|
||||||
"You are using a different version than the room you are trying to connect to");
|
"You are using a different version than the room you are trying to connect to");
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
case Network::RoomMember::State::RoomIsFull:
|
case Network::RoomMember::Error::RoomIsFull:
|
||||||
LOG_ERROR(Network, "The room is full");
|
LOG_ERROR(Network, "The room is full");
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
default:
|
case Network::RoomMember::Error::HostKicked:
|
||||||
|
LOG_ERROR(Network, "You have been kicked by the host");
|
||||||
|
break;
|
||||||
|
case Network::RoomMember::Error::HostBanned:
|
||||||
|
LOG_ERROR(Network, "You have been banned by the host");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,6 +145,15 @@ static void OnStatusMessageReceived(const Network::StatusMessageEntry& msg) {
|
|||||||
case Network::IdMemberLeave:
|
case Network::IdMemberLeave:
|
||||||
message = fmt::format("{} has left", msg.nickname);
|
message = fmt::format("{} has left", msg.nickname);
|
||||||
break;
|
break;
|
||||||
|
case Network::IdMemberKicked:
|
||||||
|
message = fmt::format("{} has been kicked", msg.nickname);
|
||||||
|
break;
|
||||||
|
case Network::IdMemberBanned:
|
||||||
|
message = fmt::format("{} has been banned", msg.nickname);
|
||||||
|
break;
|
||||||
|
case Network::IdAddressUnbanned:
|
||||||
|
message = fmt::format("{} has been unbanned", msg.nickname);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!message.empty())
|
if (!message.empty())
|
||||||
std::cout << std::endl << "* " << message << std::endl << std::endl;
|
std::cout << std::endl << "* " << message << std::endl << std::endl;
|
||||||
@ -358,6 +378,7 @@ int main(int argc, char** argv) {
|
|||||||
member->BindOnChatMessageRecieved(OnMessageReceived);
|
member->BindOnChatMessageRecieved(OnMessageReceived);
|
||||||
member->BindOnStatusMessageReceived(OnStatusMessageReceived);
|
member->BindOnStatusMessageReceived(OnStatusMessageReceived);
|
||||||
member->BindOnStateChanged(OnStateChanged);
|
member->BindOnStateChanged(OnStateChanged);
|
||||||
|
member->BindOnError(OnNetworkError);
|
||||||
LOG_DEBUG(Network, "Start connection to {}:{} with nickname {}", address, port,
|
LOG_DEBUG(Network, "Start connection to {}:{} with nickname {}", address, port,
|
||||||
nickname);
|
nickname);
|
||||||
member->Join(nickname, Service::CFG::GetConsoleIdHash(system), address.c_str(), port, 0,
|
member->Join(nickname, Service::CFG::GetConsoleIdHash(system), address.c_str(), port, 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user