Skip to content

Instantly share code, notes, and snippets.

@ChristianHohlfeld
Created October 4, 2018 20:34
Show Gist options
  • Save ChristianHohlfeld/7e6e205cc4e6a3fce25a3b51bcc019c0 to your computer and use it in GitHub Desktop.
Save ChristianHohlfeld/7e6e205cc4e6a3fce25a3b51bcc019c0 to your computer and use it in GitHub Desktop.
GameClient.h
#pragma once
//
// GameClient.h
// UDPTEST
//
// Created by Christian Hohlfeld on 16.09.18.
//
#ifndef GameClient_h
#define GameClient_h
#include "yojimbo.h"
#include <stdio.h>
#include "GameAdapter.h"
#include "GameConnectionConfig.h"
class GameClient
{
public:
GameClient(yojimbo::Allocator& allocator, const yojimbo::Address* address, yojimbo::Adapter& adapter, yojimbo::ClientServerConfig& clientServerConfig, double time);
~GameClient();
void SetServerAddress(yojimbo::Address* serverAddress);
void SendTestMessage(float positionX, float positionY, float rotation);
void SendPackets();
void ReceivePackets();
void AdvanceTime(double time);
bool ConnectionFailed();
bool IsDisconnected();
void SendMsg(yojimbo::Message* message);
yojimbo::Address GetAddress();
void InsecureConnect(const uint8_t privateKey[], uint64_t clientId);
yojimbo::Client* GetClient() { return m_client; }
uint64_t GetClientId() { return m_clientId; }
void ProcessMessages();
long time;
private:
void ProcessMessage(yojimbo::Message* message);
void ProcessTestMessage(MyMessage* message);
yojimbo::Client* m_client;
yojimbo::Address* m_serverAddress = nullptr;
uint64_t m_clientId;
int numChannels = 0;
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment