Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Networking Services #410

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
37f14ba
Make internet ranking settings configurable
Starz0r Mar 11, 2020
a6dde0d
Include CryptoPP dependencies in CMake build lists
Starz0r May 22, 2020
0b26c6f
Submit score data to specified IR Service API
Starz0r May 22, 2020
9736ecd
Add Internet Ranking options to the settings menu
Starz0r Sep 6, 2020
ece4f02
Get JWT from IR and use it when submitting score to the server
Starz0r Sep 6, 2020
76453e5
Merge remote-tracking branch 'upstream/master' into network-services
Starz0r Sep 6, 2020
f088c0a
Merge remote-tracking branch 'upstream/master' into network-services
Starz0r Oct 6, 2020
ff5ae59
NetworkingServices class to facilitate interactions over the network
Starz0r Oct 8, 2020
ef8e87b
Enable and Initialize the NetworkingService class at program startup
Starz0r Oct 8, 2020
2b95d62
Submit scoring when connected to Networking Services
Starz0r Oct 8, 2020
85a2f5b
Retrieve scores of a track from a specific SHA3 hash
Starz0r Oct 11, 2020
107e790
Calculate a SHA3-512 hash for songs when pushing songs to the Lua state
Starz0r Oct 11, 2020
a054767
Push NetServ Lua functions to the state
Starz0r Oct 11, 2020
fb1b724
Attempt to fix cross-platform building on macOS and GNU/Linux
Starz0r Oct 12, 2020
8308de8
Don't index a number value or something
Starz0r Oct 12, 2020
41c50cf
More Linux dependencies while macOS has to build CryptoPP from scratch
Starz0r Oct 12, 2020
4f3c250
Ubuntu only has Libcrypto6 so build from scratch there too
Starz0r Oct 12, 2020
ebc58bd
Check why macOS can't see the GNUmakefile for CryptoPP
Starz0r Oct 12, 2020
77c8b02
Try building CryptoPP with a different prefix
Starz0r Oct 12, 2020
ca53f11
Linux needs sudo to install libs and change prefix directory for macOS
Starz0r Oct 12, 2020
053fc16
Change Linux prefix and CryptoPP not LibCryptoPP
Starz0r Oct 12, 2020
fe3765c
Expose CryptoPP in CMakeLists file
Starz0r Oct 12, 2020
6fb2273
Revert build.yml changes
Starz0r Dec 11, 2020
31d2527
Push the SHA3 hash of the current chart to the Lua data table
Starz0r Dec 11, 2020
c1d0e0d
GET Request instead of POST for getting profile information
Starz0r Dec 11, 2020
37a63d0
Don't push score as the accuracy to the Lua data table
Starz0r Dec 11, 2020
6622776
Lua API to query whether the current user is connected to a NetServ
Starz0r Dec 11, 2020
27c37c3
Disable Multiplayer and Nautica downloads while NetServ is enabled
Starz0r Dec 11, 2020
e4765e3
Show NetServ highscores on a track at the score screen
Starz0r Dec 11, 2020
059179b
Show local online record on the Song Wheel
Starz0r Feb 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ jobs:
uses: actions/upload-artifact@master
with:
name: Game_mac
path: bin
path: bin
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ find_package(Vorbis REQUIRED)
find_package(OGG REQUIRED)
find_package(LibArchive REQUIRED)
find_package(Iconv REQUIRED)
find_package(CryptoPP REQUIRED)

# All projects use unicode define
# this is mainly for windows functions either being defined to call A or W prefixed functions
Expand Down
2 changes: 2 additions & 0 deletions Main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ target_link_libraries(usc-game nlohmann_json)

target_link_libraries(usc-game ${SDL2_LIBRARY})
target_link_libraries(usc-game ${LibArchive_LIBRARIES})
target_link_libraries(usc-game ${CryptoPP_LIBRARIES})
target_include_directories(usc-game SYSTEM PRIVATE ${LibArchive_INCLUDE_DIRS})
target_include_directories(usc-game SYSTEM PRIVATE ${CryptoPP_INCLUDE_DIRS})

if(WIN32)
target_link_libraries(usc-game
Expand Down
1 change: 1 addition & 0 deletions Main/include/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern class JobSheduler* g_jobSheduler;
extern class Input g_input;
extern class SkinConfig* g_skinConfig;
extern class TransitionScreen* g_transition;
extern class NetworkingServices* g_networkingServices;

class Application
{
Expand Down
7 changes: 6 additions & 1 deletion Main/include/GameConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ DefineEnum(GameConfigKeys,
// Gameplay options
GaugeType,
MirrorChart,
RandomizeChart)
RandomizeChart,

// Internet Ranking
IRBaseURL,
IRUsername,
IRPassword)

DefineEnum(GaugeTypes,
Normal,
Expand Down
43 changes: 43 additions & 0 deletions Main/include/NetworkingServices.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once

#include <string>
#include <thread>
#include "GameConfig.hpp"
#include "Game.hpp"
#include "lua.hpp"

class NetworkingServices
{
public:
NetworkingServices();
void Init(GameConfig* config);
bool TryLogin();
void QueueHeartbeat();
virtual bool SubmitScore(class Game* game, GameFlags m_flags);
bool ConnectionStatus();
void PushLuaFunctions(lua_State* L);
int lGetScoresForTrack(lua_State* L);
int lIsConnected(lua_State* L);

private:
bool Heartbeat();
void WaitForHeartbeat();

// Configurable
String m_serviceUrl;
String m_username;
String m_password;

// Connection Dependant
bool m_isConnected;
String m_refreshToken;
String m_bearerToken;

// Static
std::thread::id m_heartbeat;

// Lua
Map<struct lua_State*, class LuaBindable*> m_boundStates;
};

extern class NetworkingServices;
14 changes: 14 additions & 0 deletions Main/src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "SkinConfig.hpp"
#include "SkinHttp.hpp"
#include "ShadedMesh.hpp"
#include "NetworkingServices.hpp"

#ifdef EMBEDDED
#define NANOVG_GLES2_IMPLEMENTATION
Expand All @@ -48,6 +49,7 @@ Graphics::Window *g_gameWindow = nullptr;
Application *g_application = nullptr;
JobSheduler *g_jobSheduler = nullptr;
TransitionScreen *g_transition = nullptr;
NetworkingServices* g_networkingServices = nullptr;
Input g_input;

// Tickable queue
Expand Down Expand Up @@ -880,6 +882,15 @@ bool Application::m_Init()
Path::CreateDir(Path::Absolute("replays"));
Path::CreateDir(Path::Absolute("crash_dumps"));

// Initalize NetworkServices
g_networkingServices = new NetworkingServices();
g_networkingServices->Init(&g_gameConfig);
auto net_loggedin = g_networkingServices->TryLogin();
if (net_loggedin)
{
g_networkingServices->QueueHeartbeat();
}

return true;
}
void Application::m_MainLoop()
Expand Down Expand Up @@ -2353,6 +2364,9 @@ void Application::SetLuaBindings(lua_State *state)

//http
m_skinHttp.PushFunctions(state);

//netserv
g_networkingServices->PushLuaFunctions(state);
}

bool JacketLoadingJob::Run()
Expand Down
5 changes: 5 additions & 0 deletions Main/src/GameConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ void GameConfig::InitDefaults()
Set(GameConfigKeys::MultiplayerUsername, "");

Set(GameConfigKeys::EnableFancyHighwayRoll, true);

// Internet Ranking
Set(GameConfigKeys::IRBaseURL, "https://api.orchestra.fm");
Set(GameConfigKeys::IRUsername, "");
Set(GameConfigKeys::IRPassword, "");

//Gameplay
Set(GameConfigKeys::RandomizeChart, false);
Expand Down
Loading