citra-emu
/
citra-canary
Archived
1
0
Fork 0

citra: add status messages and fix missing errors

This commit is contained in:
zhupengfei 2018-11-09 21:56:58 +08:00
parent 0319e51960
commit 0823d8e009
No known key found for this signature in database
GPG Key ID: DD129E108BD09378
1 changed files with 23 additions and 0 deletions

View File

@ -99,6 +99,10 @@ static void OnStateChanged(const Network::RoomMember::State& state) {
"connected to the Room"); "connected to the Room");
exit(1); exit(1);
break; break;
case Network::RoomMember::State::ConsoleIdCollision:
LOG_ERROR(Network, "Your Console ID conflicted with someone else in the Room");
exit(1);
break;
case Network::RoomMember::State::WrongPassword: case Network::RoomMember::State::WrongPassword:
LOG_ERROR(Network, "Room replied with: Wrong password"); LOG_ERROR(Network, "Room replied with: Wrong password");
exit(1); exit(1);
@ -108,6 +112,10 @@ static void OnStateChanged(const Network::RoomMember::State& state) {
"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:
LOG_ERROR(Network, "The room is full");
exit(1);
break;
default: default:
break; break;
} }
@ -117,6 +125,20 @@ static void OnMessageReceived(const Network::ChatEntry& msg) {
std::cout << std::endl << msg.nickname << ": " << msg.message << std::endl << std::endl; std::cout << std::endl << msg.nickname << ": " << msg.message << std::endl << std::endl;
} }
static void OnStatusMessageReceived(const Network::StatusMessageEntry& msg) {
std::string message;
switch (msg.type) {
case Network::IdMemberJoin:
message = fmt::format("{} has joined", msg.nickname);
break;
case Network::IdMemberLeave:
message = fmt::format("{} has left", msg.nickname);
break;
}
if (!message.empty())
std::cout << std::endl << "* " << message << std::endl << std::endl;
}
static void InitializeLogging() { static void InitializeLogging() {
Log::Filter log_filter(Log::Level::Debug); Log::Filter log_filter(Log::Level::Debug);
log_filter.ParseFilterString(Settings::values.log_filter); log_filter.ParseFilterString(Settings::values.log_filter);
@ -334,6 +356,7 @@ int main(int argc, char** argv) {
if (use_multiplayer) { if (use_multiplayer) {
if (auto member = Network::GetRoomMember().lock()) { if (auto member = Network::GetRoomMember().lock()) {
member->BindOnChatMessageRecieved(OnMessageReceived); member->BindOnChatMessageRecieved(OnMessageReceived);
member->BindOnStatusMessageReceived(OnStatusMessageReceived);
member->BindOnStateChanged(OnStateChanged); member->BindOnStateChanged(OnStateChanged);
LOG_DEBUG(Network, "Start connection to {}:{} with nickname {}", address, port, LOG_DEBUG(Network, "Start connection to {}:{} with nickname {}", address, port,
nickname); nickname);