Browse Source

removed old client networking code

Kajetan Johannes Hammerle 3 years ago
parent
commit
592e8391d5

+ 2 - 2
client/Game.cpp

@@ -28,7 +28,7 @@ pointIndex(0), moveSpeed(0.125f), movedLength(0.0f), mode(Mode::AUTO) {
         v.setAngles(i * 360.0f / cameraPoints.getCapacity(), 0.0f).mul(mid * 0.5f).add(offset);
 
         q.mul(Quaternion(Vector(r.nextFloat() * 360.0f, r.nextFloat() * -90.0f), -10.0f));
-        cameraPoints.add( {v, q, 0.0f});
+        cameraPoints.add({v, q, 0.0f});
     }
     updateDistances();
 }
@@ -81,7 +81,7 @@ void Game::tick() {
         }
 
         if(control.keys.test3.getDownTime() == 1) {
-            cameraPoints.add( {pos, rotation, 0.0f});
+            cameraPoints.add({pos, rotation, 0.0f});
         }
     } else if(mode == Mode::AUTO) {
         movedLength += moveSpeed;

+ 0 - 75
client/network/Client.cpp

@@ -1,75 +0,0 @@
-#include <iostream>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <cstring>
-#include <stdexcept>
-#include <unistd.h>
-#include <poll.h>
-
-#include "client/network/Client.h"
-#include "common/stream/Stream.h"
-
-Client::Client() {
-}
-
-Client::~Client() {
-    if(connectionSocket != -1) {
-        close(connectionSocket);
-    }
-}
-
-bool Client::start(const string& ip, unsigned short port, IClientListener* listener) {
-    connectionSocket = socket(AF_INET, SOCK_STREAM, 0);
-    if(connectionSocket == -1) {
-        throw runtime_error(string("cannot create socket: ") + strerror(errno));
-    }
-
-    struct sockaddr_in socketData;
-    memset(&socketData, 0, sizeof (struct sockaddr_in));
-    socketData.sin_family = AF_INET;
-    socketData.sin_port = htons(port);
-    if(inet_aton(ip.data(), &socketData.sin_addr) == 0) {
-        throw runtime_error(ip + " is not a valid ip");
-    }
-
-    if(connect(connectionSocket, (struct sockaddr*) &socketData, sizeof (struct sockaddr_in)) == 0) {
-        clientListener = listener;
-        shouldRun = true;
-        serverListenThread = thread(&Client::listenOnServer, this);
-        return true;
-    }
-    return false;
-}
-
-void Client::stop() {
-    shouldRun = false;
-    serverListenThread.join();
-}
-
-void Client::listenOnServer() {
-    struct pollfd fds;
-    fds.fd = connectionSocket;
-    fds.events = POLLIN;
-    fds.revents = 0;
-
-    clientListener->onServerJoin(connectionSocket);
-
-    Stream st;
-
-    while(shouldRun) {
-        int pollData = poll(&fds, 1, 100);
-        if(pollData > 0) {
-            st.readSocket(connectionSocket);
-            if(st.hasData()) {
-                clientListener->onServerPackage(connectionSocket, st);
-            } else {
-                // server closed connection
-                clientListener->onServerClose(connectionSocket);
-                break;
-            }
-        } else if(pollData == -1) {
-            cout << "poll error: " << strerror(errno) << endl;
-        }
-    }
-}
-

+ 0 - 31
client/network/Client.h

@@ -1,31 +0,0 @@
-#ifndef CLIENT_H
-#define CLIENT_H
-
-#include <string>
-#include <thread>
-
-#include "client/network/IClientListener.h"
-
-using namespace std;
-
-class Client final {
-public:
-    Client();
-    virtual ~Client();
-
-    bool start(const string& ip, unsigned short port, IClientListener* listener);
-    void stop();
-
-private:
-    void listenOnServer();
-
-    int connectionSocket = -1;
-    volatile bool shouldRun = false;
-
-    thread serverListenThread;
-
-    IClientListener* clientListener;
-};
-
-#endif
-

+ 0 - 10
client/network/ClientListener.cpp

@@ -1,10 +0,0 @@
-#include "client/network/ClientListener.h"
-
-void ClientListener::onServerJoin(int serverSocket) {
-}
-
-void ClientListener::onServerPackage(int serverSocket, Stream& in) {
-}
-
-void ClientListener::onServerClose(int socket) {
-}

+ 0 - 13
client/network/ClientListener.h

@@ -1,13 +0,0 @@
-#ifndef CLIENTLISTENER_H
-#define CLIENTLISTENER_H
-
-#include "client/network/IClientListener.h"
-
-class ClientListener : public IClientListener {
-public:
-    void onServerJoin(int serverSocket) override;
-    void onServerPackage(int serverSocket, Stream& in) override;
-    void onServerClose(int socket) override;
-};
-
-#endif

+ 0 - 14
client/network/IClientListener.h

@@ -1,14 +0,0 @@
-#ifndef ICLIENTLISTENER_H
-#define ICLIENTLISTENER_H
-
-#include "common/stream/Stream.h"
-
-class IClientListener {
-public:
-    virtual ~IClientListener() = default;
-    virtual void onServerJoin(int serverSocket) = 0;
-    virtual void onServerPackage(int serverSocket, Stream& in) = 0;
-    virtual void onServerClose(int socket) = 0;
-};
-
-#endif

+ 2 - 2
client/rendering/Engine.h

@@ -28,13 +28,13 @@ private:
     Framebuffers& fb;
     const WindowSize& size;
     RenderSettings& renderSettings;
-    
+
     Frustum frustum;
     MatrixStack model;
     FontRenderer fontRenderer;
     NoiseTexture ssaoNoise;
     Mesh rectangle;
-    
+
     Matrix worldProj;
     Matrix worldView;
     Matrix worldShadowProj;