OOP for DirectPlay Peer to Peer program
I have read a little about peer to peer programming using DirectPlay. Specificly from Multiplayer Game programming by Todd Barron and what I want to do is convert his peer to peer windows application to a more object oriented approach. Namely for the networking aspects of the program. The problem is I am not sure how. Should I start from scratch.
I have an outline for setting up a peer to peer session.
Initialize Peer to Peer Session
1. Initialize Com
2. Initialize the Message Handler
3. Create a Device Address
4. Set the Service Provider
5. Create a host address
Hosting a Session
1. Set up peer infromation using the SetPeerInfo() function
2. Set up the application description
3. Optional, add the port number to the device address
4. Host the the game with the IDirectPlay8Peer::Host() function
Joining a Session
1. Set up peer information
2. Set up application description
3. Add host name to host address
4. Optional, add port number to HostAdress
5. Call the Connect function.
He uses global variables that are used in multiple routines accross the application such as IDirectPlay8Peer* g_pDP
the main interface for the directplaypeer object. How should I isolate these in a class, should I make several friend classes. Maybe this is to complex for me to handle at this stage. I need some direction/ advice.