Skip to content

Commit

Permalink
Merge pull request #1 from Cattn/web
Browse files Browse the repository at this point in the history
Add Discord RPC + Clean up server
  • Loading branch information
Cattn authored Aug 9, 2024
2 parents c46e135 + 299005d commit 48ee771
Show file tree
Hide file tree
Showing 7 changed files with 4,470 additions and 4,317 deletions.
109 changes: 55 additions & 54 deletions dataServer.h
Original file line number Diff line number Diff line change
@@ -1,55 +1,56 @@
#ifndef DATASERVER_H
#define DATASERVER_H

#include <vector>
#include <iostream>
#include <string>
#include <cstring>
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#pragma comment(lib, "ws2_32.lib")
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define SOCKET int
#define INVALID_SOCKET -1
#define closesocket close
#endif

#include <thread>
#include <sstream>
#include <json.hpp>

void sendJsonToServer(const char *json_data, const char *path);
void sendShotDataToServer();
void sendTurnDataToServer();
void updateData(const char *value, const std::string &dataTypeInfo, const std::string &path);
void resetData();
void updateDoubleData(const double &value, const std::string &dataTypeInfo, const std::string &path);
class HoleClass
{
public:
std::string name;
int shots;
int score;
int par;
int aimTime;
int ranking;
std::string path = "hole";

void clear()
{
name = "";
shots = 0;
score = 0;
par = 0;
aimTime = 0;
ranking = 0;
};
};

void sendHoleDataToServer(HoleClass& hole);
#ifndef DATASERVER_H
#define DATASERVER_H

#include <vector>
#include <iostream>
#include <string>
#include <cstring>
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#pragma comment(lib, "ws2_32.lib")
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define SOCKET int
#define INVALID_SOCKET -1
#define closesocket close
#endif

#include <thread>
#include <sstream>
#include <json.hpp>

void sendJsonToServer(const char *json_data, const char *path);
void sendShotDataToServer();
void sendTurnDataToServer();
void updateData(const std::string& value, const std::string &dataTypeInfo, const std::string &path);
void resetData();
void updateDoubleData(const double &value, const std::string &dataTypeInfo, const std::string &path);
class HoleClass
{
public:
std::string name;
std::string holeName;
int shots;
int score;
int par;
int aimTime;
int ranking;
std::string path = "hole";

void clear()
{
name = "";
shots = 0;
score = 0;
par = 0;
aimTime = 0;
ranking = 0;
};
};

void sendHoleDataToServer(HoleClass& hole);
#endif
Loading

0 comments on commit 48ee771

Please sign in to comment.