From 63d71f0d2459c82b55cc2a0f73632c6ab0fd6e90 Mon Sep 17 00:00:00 2001 From: Jim Ankrom Date: Sat, 20 Dec 2014 14:57:40 -0500 Subject: [PATCH] #6 Control updates to support player lifecycle --- src/core/PlayerController.h | 20 ++++++++++++++++---- src/core/PlayerManager.h | 17 +++++++---------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/core/PlayerController.h b/src/core/PlayerController.h index ff60171..cdad864 100644 --- a/src/core/PlayerController.h +++ b/src/core/PlayerController.h @@ -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" @@ -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); diff --git a/src/core/PlayerManager.h b/src/core/PlayerManager.h index 9162bb2..4e8be20 100644 --- a/src/core/PlayerManager.h +++ b/src/core/PlayerManager.h @@ -18,16 +18,6 @@ #include // 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"; @@ -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 { @@ -78,6 +74,7 @@ class PlayerManager void onBroadcast(ofxLibwebsockets::Event& args); ofPtr findPlayer(ofxLibwebsockets::Connection& conn); + private: bool _inRoundMode; std::list > _players;