Add udp status to debug menu

This commit is contained in:
Jack Garrard 2022-10-23 18:37:08 -07:00
parent 2654650804
commit ed83827cc1
3 changed files with 14 additions and 1 deletions

View file

@ -46,6 +46,7 @@ class SocketClient : public SocketBase {
u16 getLocalUdpPort();
s32 setPeerUdpPort(u16 port);
const char* getUdpStateChar();
u32 getSendCount() { return mSendQueue.getCount(); }
u32 getSendMaxCount() { return mSendQueue.getMaxCount(); }

View file

@ -118,6 +118,7 @@ void drawMainHook(HakoniwaSequence *curSequence, sead::Viewport *viewport, sead:
}
gTextWriter->printf("Client Socket Connection Status: %s\n", Client::instance()->mSocket->getStateChar());
gTextWriter->printf("Udp socket status: %s\n", Client::instance()->mSocket->getUdpStateChar());
//gTextWriter->printf("nn::socket::GetLastErrno: 0x%x\n", Client::instance()->mSocket->socket_errno);
gTextWriter->printf("Connected Players: %d/%d\n", Client::getConnectCount() + 1, Client::getMaxPlayerCount());

View file

@ -88,7 +88,7 @@ nn::Result SocketClient::init(const char* ip, u16 port) {
}
udpAddress.address = hostAddress;
udpAddress.port = nn::socket::InetHtons(41553);
udpAddress.port = nn::socket::InetHtons(0);
udpAddress.family = 2;
this->udp_addr = udpAddress;
this->has_recv_udp = false;
@ -155,6 +155,17 @@ s32 SocketClient::setPeerUdpPort(u16 port) {
}
const char* SocketClient::getUdpStateChar() {
if (this->udp_addr.port == 0) {
return "Waiting for handshake";
}
if (!this->has_recv_udp) {
return "Waiting for holepunch";
}
return "Utilizing UDP";
}
bool SocketClient::send(Packet *packet) {
if (this->socket_log_state != SOCKET_LOG_CONNECTED)