Skip to content
Snippets Groups Projects
Commit 3d3ac83e authored by OleL's avatar OleL
Browse files

Moved .ino

parent e8175893
No related branches found
No related tags found
No related merge requests found
......@@ -153,8 +153,8 @@ void joinGame() {
Serial.printf("Received ip: %s", ip.c_str());
//client = new GameClient(ui, &badge, player);
//client->joinGame();
client = new GameClient(ui, &badge, player);
client->joinGame(ip);
#ifdef DEBUG
Serial.printf("Join - Ende\n");
#endif
......
......@@ -37,12 +37,18 @@ void GameClient::startGame() {
}
void GameClient::joinGame() {
void GameClient::joinGame(String ip) {
badge->setVibrator(true);
delay(200);
badge->setVibrator(false);
playerList->addMenuItem(new MenuItem(player->getNickname(), []() {}));
ui->open(playerList);
client->connect(ip, SERVER_PORT);
client->print(player->getNickname());
client->flush();
String recv = client->readStringUntil('\n');
Serial.printf("RECV: %s", recv.c_str());
}
......
......@@ -10,6 +10,8 @@
#include "PlayerListMenu.hpp"
#include "Player.hpp"
#define SERVER_PORT 4803
class GameClient {
public:
GameClient(WindowSystem *ui, Badge *badge, Player *player) : ui(ui), badge(badge), player(player) {}
......@@ -28,7 +30,7 @@ private:
WindowSystem *ui;
Player *player;
Badge *badge;
char *host = "127.000.000.1"; // MaxArraySize
char *host = "127.0.0.1"; // MaxArraySize
PlayerListMenu *playerList = new PlayerListMenu(9);
WiFiClient *client; // the client connected on client side
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment