Skip to content

Commit

Permalink
#6 Control updates to support player lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
JimAnkrom committed Dec 20, 2014
1 parent 88b9aa7 commit 63d71f0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
20 changes: 16 additions & 4 deletions src/core/PlayerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
Actions are routed to the controller from messages recieved by PlayerManager
The player lifecycle is as follows:
* Connect
* Configure
* Queue
* Calibrate
*
*/
#include "Player.h"

Expand All @@ -17,14 +26,17 @@ class PlayerController
public:
/*
Player Actions
*/
// Player connected
// Player connected - called by message from player
void connect(Player& player);
// Player has entered the 'lobby'
// Player configuring - called by message from player
void configure(Player& player);
// Player has entered the 'lobby' - called by ... ?
void queue(Player& player);
// Calibrate Player Position
// Calibrate Player Position - called by player, but this likely is a complicated step
void calibrate(Player& player);
// Player has started their game.
// Player has started their game - called by player
void start(Player& player);
// Player has quit. Called by player.
void quit(Player& player);
Expand Down
17 changes: 7 additions & 10 deletions src/core/PlayerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@
#include <list>

// Engine.io client packet type prefixes
//var packets = exports.packets = {
// open: 0 // non-ws
// , close: 1 // non-ws
// , ping: 2
// , pong: 3
// , message: 4
// , upgrade: 5
// , noop: 6
//};

const std::string PACKET_OPEN = "0";
const std::string PACKET_CLOSE = "1";
const std::string PACKET_PING = "2";
Expand All @@ -45,6 +35,12 @@ const std::string MESSAGE_YPR = "ypr";
// Action
const std::string MESSAGE_ACT = "act";

// Action message prefixes
const std::string ACTION_CONFIGURE = "cfg";
const std::string ACTION_START = "start";
const std::string ACTION_CALIBRATE = "cal";
const std::string ACTION_QUIT = "quit";

class PlayerManager
: public PlayerEventSource
, public ControlEventSource {
Expand Down Expand Up @@ -78,6 +74,7 @@ class PlayerManager
void onBroadcast(ofxLibwebsockets::Event& args);

ofPtr<Player> findPlayer(ofxLibwebsockets::Connection& conn);

private:
bool _inRoundMode;
std::list<ofPtr<Player> > _players;
Expand Down

0 comments on commit 63d71f0

Please sign in to comment.