Skip to content

Instantly share code, notes, and snippets.

@ChristianHohlfeld
Created October 4, 2018 20:39
Show Gist options
  • Save ChristianHohlfeld/cdc877dda059683e0e1b70955219f2ce to your computer and use it in GitHub Desktop.
Save ChristianHohlfeld/cdc877dda059683e0e1b70955219f2ce to your computer and use it in GitHub Desktop.
GameAdapter.h
#ifndef GameAdapter_h
#define GameAdapter_h
#include <stdio.h>
#include "yojimbo.h"
#include "GameMessageFactory.h"
class GameServer;
class GameAdapter : public yojimbo::Adapter {
public:
explicit GameAdapter(yojimbo::Allocator* allocator = NULL) :
myAllocator(allocator) {}
void setGameServer(GameServer* gs) {
m_game_serverRef = gs;
}
yojimbo::MessageFactory* CreateMessageFactory(yojimbo::Allocator& allocator) override {
return YOJIMBO_NEW(allocator, GameMessageFactory, *myAllocator);
}
void OnServerClientConnected(int clientIndex) override;
void OnServerClientDisconnected(int clientIndex) override;
private:
GameServer* m_game_serverRef;
yojimbo::Allocator* myAllocator;
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment