Skip to content

Instantly share code, notes, and snippets.

@ChristianHohlfeld
Created October 4, 2018 20:32
Show Gist options
  • Save ChristianHohlfeld/4d71f9e46288a7206fbc7f032c175a66 to your computer and use it in GitHub Desktop.
Save ChristianHohlfeld/4d71f9e46288a7206fbc7f032c175a66 to your computer and use it in GitHub Desktop.
GameServer.h
//
// GameServer.h
// UDPTEST
//
// Created by Christian Hohlfeld on 16.09.18.
//
#ifndef GameServer_h
#define GameServer_h
#include "yojimbo.h"
#include <stdio.h>
#include "GameConnectionConfig.h"
#include "MyMessage.h"
#include "GameAdapter.h"
class GameServer
{
public:
GameServer(yojimbo::Allocator& allocator, const yojimbo::Address* address, yojimbo::Adapter& myAdapter, yojimbo::ClientServerConfig& clientServerConfig, double time);
~GameServer();
void ClientConnected(int clientIndex);
void ClientDisconnected(int clientIndex);
void Start();
void SendPackets();
void ReceivePackets();
void AdvanceTime(double time);
bool IsRunning() { return m_running; }
int GetNumConnectedClients();
void ProcessMessages();
yojimbo::Address GetAddress();
//for testing
float getReceivedXPos();
float getReceivedYPos();
float getReceivedRotation();
long m_time;
private:
void ProcessMessage(int clientIndex, yojimbo::Message* message);
void ProcessMyMessage(int clientIndex, MyMessage* message);
void setReceivedDataFromMessage(MyMessage* message);
yojimbo::Server* m_serverRef;
bool m_running = false;
int numChannels = 0;
//Testing
float xPosReceived = 0.0f;
float yPosReceived = 0.0f;
float m_receivedRotation = 0.0f;
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment