Skip to content

Commit

Permalink
ETTP report options/eval enter/leave
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Mar 27, 2018
1 parent ccb60c7 commit 5b36262
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 31 deletions.
78 changes: 48 additions & 30 deletions src/NetworkSyncManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ std::map<ETTClientMessageTypes, std::string> ettClientMessageMap = {
{ ettpc_missingchart, "missingchart" },
{ ettpc_startingchart, "startingchart" },
{ ettpc_notstartingchart, "notstartingchart" },
{ ettpc_openoptions, "openoptions" },
{ ettpc_closeoptions, "closeoptions" },
{ ettpc_openeval, "openeval" },
{ ettpc_closeeval, "closeeval" },
};
std::map<std::string, ETTServerMessageTypes> ettServerMessageMap = {
{ "hello", ettps_hello },
Expand Down Expand Up @@ -69,36 +73,12 @@ void NetworkSyncManager::OnMusicSelect()
{
}
void NetworkSyncManager::OffMusicSelect() { }
void NetworkSyncManager::OnRoomSelect()
{
if (curProtocol != nullptr)
curProtocol->OnRoomSelect();
}
void NetworkSyncManager::OffRoomSelect()
{
if (curProtocol != nullptr)
curProtocol->OffRoomSelect();
}
void NetworkSyncManager::OnOptions()
{
if (curProtocol != nullptr)
curProtocol->OnOptions();
}
void NetworkSyncManager::OffOptions()
{
if (curProtocol != nullptr)
curProtocol->OffOptions();
}
void NetworkSyncManager::OnEval()
{
if (curProtocol != nullptr)
curProtocol->OnEval();
}
void NetworkSyncManager::OffEval()
{
if (curProtocol != nullptr)
curProtocol->OffEval();
}
void NetworkSyncManager::OnRoomSelect() { }
void NetworkSyncManager::OffRoomSelect() { }
void NetworkSyncManager::OnOptions() { }
void NetworkSyncManager::OffOptions() { }
void NetworkSyncManager::OnEval() { }
void NetworkSyncManager::OffEval() { }
void NetworkSyncManager::ReportScore( int playerID, int step, int score, int combo, float offset ) { }
void NetworkSyncManager::ReportSongOver() { }
void NetworkSyncManager::ReportStyle() {}
Expand Down Expand Up @@ -266,6 +246,44 @@ void SMOProtocol::OffOptions()
ReportPlayerOptions();
}


void ETTProtocol::OffEval()
{
if (ws == nullptr)
return;
json j;
j["type"] = ettClientMessageMap[ettpc_closeeval];
j["id"] = msgId++;
ws->send(j.dump().c_str());
}
void ETTProtocol::OnEval()
{
if (ws == nullptr)
return;
json j;
j["type"] = ettClientMessageMap[ettpc_openeval];
j["id"] = msgId++;
ws->send(j.dump().c_str());
}
void ETTProtocol::OnOptions()
{
if (ws == nullptr)
return;
json j;
j["type"] = ettClientMessageMap[ettpc_openoptions];
j["id"] = msgId++;
ws->send(j.dump().c_str());
}
void ETTProtocol::OffOptions()
{
if (ws == nullptr)
return;
json j;
j["type"] = ettClientMessageMap[ettpc_closeoptions];
j["id"] = msgId++;
ws->send(j.dump().c_str());
}

void SMOProtocol::close()
{
serverVersion = 0;
Expand Down
10 changes: 9 additions & 1 deletion src/NetworkSyncManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ enum ETTClientMessageTypes {
ettpc_haschart,
ettpc_missingchart,
ettpc_startingchart,
ettpc_notstartingchart,
ettpc_notstartingchart,
ettpc_openoptions,
ettpc_closeoptions,
ettpc_openeval,
ettpc_closeeval,
ettpc_end
};
/** @brief A special foreach loop going through each NSScoreBoardColumn. */
Expand Down Expand Up @@ -249,6 +253,10 @@ class ETTProtocol : public NetProtocol { // Websockets using uwebsockets sending
void ReportSongOver(NetworkSyncManager* n) override;
void SelectUserSong(NetworkSyncManager* n, Song* song) override;
void StartRequest(NetworkSyncManager* n, short position) override;
void OnOptions() override;
void OffOptions() override;
void OnEval() override;
void OffEval() override;
/*
void ReportScore(NetworkSyncManager* n, int playerID, int step, int score, int combo, float offset, int numNotes) override;
void ReportScore(NetworkSyncManager* n, int playerID, int step, int score, int combo, float offset) override;
Expand Down

0 comments on commit 5b36262

Please sign in to comment.