update gui

This commit is contained in:
Logan McNaughton committed 2023-09-01 09:01:10 -06:00
1 parent 38d98f1914
commit 862c0a8b46
5 files changed
+22 -18

No files matched your search

+3 -2
View File
@@ -175,9 +175,10 @@ void CreateRoom::createRoom()
json.insert("game_name", QString(rom_settings.goodname));
json.insert("client_sha", QStringLiteral(GUI_VERSION));
json.insert("netplay_version", NETPLAY_VER);
json.insert("emulator", "simple64");
addAuthData(webSocket, &json);
sendNetplayMessage(webSocket, json);
QJsonDocument json_doc(json);
webSocket->sendTextMessage(json_doc.toJson());
}
void CreateRoom::processTextMessage(QString message)
+6 -3
View File
@@ -178,7 +178,8 @@ void JoinRoom::joinGame()
json.insert("MD5", QString(rom_settings.MD5));
json.insert("port", room_port);
sendNetplayMessage(webSocket, json);
QJsonDocument json_doc(json);
webSocket->sendTextMessage(json_doc.toJson());
}
else
{
@@ -257,8 +258,10 @@ void JoinRoom::onConnected()
QJsonObject json;
json.insert("type", "request_get_rooms");
json.insert("netplay_version", NETPLAY_VER);
json.insert("emulator", "simple64");
sendNetplayMessage(webSocket, json);
addAuthData(webSocket, &json);
QJsonDocument json_doc(json);
webSocket->sendTextMessage(json_doc.toJson());
}
void JoinRoom::processTextMessage(QString message)
+4 -7
View File
@@ -1,7 +1,6 @@
#include "netplay_common.h"
#include <QJsonDocument>
void sendNetplayMessage(QWebSocket* webSocket, QJsonObject json)
void addAuthData(QWebSocket* webSocket, QJsonObject* json)
{
QCryptographicHash hash = QCryptographicHash(QCryptographicHash::Sha256);
QByteArray currentTime = QByteArray::number(QDateTime::currentMSecsSinceEpoch());
@@ -10,9 +9,7 @@ void sendNetplayMessage(QWebSocket* webSocket, QJsonObject json)
// this auth code is emulator specific, and is only checked when the server is running with the --enable-auth option
hash.addData(QStringLiteral(NETPLAY_AUTH_CODE).toUtf8());
json.insert("auth", QString(hash.result().toHex()));
json.insert("authTime", QString(currentTime));
QJsonDocument json_doc(json);
webSocket->sendTextMessage(json_doc.toJson());
json->insert("auth", QString(hash.result().toHex()));
json->insert("authTime", QString(currentTime));
json->insert("emulator", "simple64");
}
+1 -1
View File
@@ -4,6 +4,6 @@
#include <QWebSocket>
#include <QJsonObject>
void sendNetplayMessage(QWebSocket* webSocket, QJsonObject json);
void addAuthData(QWebSocket* webSocket, QJsonObject* json);
#endif
+8 -5
View File
@@ -1,7 +1,6 @@
#include "waitroom.h"
#include "../mainwindow.h"
#include "../interface/core_commands.h"
#include "netplay_common.h"
#include <QGridLayout>
#include <QMessageBox>
#include <QJsonArray>
@@ -88,7 +87,8 @@ WaitRoom::WaitRoom(QString filename, QJsonObject room, QWebSocket *socket, QWidg
QJsonObject json;
json.insert("type", "request_players");
json.insert("port", room_port);
sendNetplayMessage(webSocket, json);
QJsonDocument json_doc(json);
webSocket->sendTextMessage(json_doc.toJson());
timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &WaitRoom::sendPing);
@@ -113,7 +113,8 @@ void WaitRoom::sendPing()
QJsonObject json;
json.insert("type", "request_motd");
json.insert("room_name", room_name);
sendNetplayMessage(webSocket, json);
QJsonDocument json_doc(json);
webSocket->sendTextMessage(json_doc.toJson());
}
webSocket->ping();
}
@@ -131,7 +132,8 @@ void WaitRoom::startGame()
QJsonObject json;
json.insert("type", "request_begin_game");
json.insert("port", room_port);
sendNetplayMessage(webSocket, json);
QJsonDocument json_doc(json);
webSocket->sendTextMessage(json_doc.toJson());
}
else
{
@@ -150,7 +152,8 @@ void WaitRoom::sendChat()
json.insert("port", room_port);
json.insert("player_name", player_name);
json.insert("message", chatEdit->text());
sendNetplayMessage(webSocket, json);
QJsonDocument json_doc(json);
webSocket->sendTextMessage(json_doc.toJson());
chatEdit->clear();
}
}