Master Server
Location: programming\c++\cvs\polylib
Files: MasterServer.cpp - for all classes
Status: Working: Needs a few extra features
This is a set of classes that supports client/server connections to a master server to allow client programs to easily find servers.
Classes
- CMasterServer - Only used in the master server application. Accepts client and server connections and sends clients a list of servers.
- CNetServer - Notifies a master server of game server.
- CNetClient - Connects to the master server to find game servers.
CNetClient
Members
void Connect();
void Sync();
void RandomServer(CSocket *);
int Servers();
ServerInfo *Server(int ServerNumber);
Example
CNetClient NetClient;
CSocket Socket;
NetClient.Connect();
..
NetClient.Sync();
..
NetClient.RandomServer(&Socket);
or
Enumerate Servers
Status settings
SERVER_DISCONNECTED: Waiting for app to call Connect()
SERVER_CONNECTING: Following the application connection steps
SERVER_CONNECTED: Client actually disconnected from master server and server information is ready for enumeration
SERVER_ERROR
Application Connection Steps (CNetClient)
- Connect to polyart to get master server IP
- Connect to master server to get server list
- Open dialog to allow user to select server
- Connect to selected server
Several classes are needed
- Server Tool class: CNetServer - To find clients
- Register Server
- Accept new clients
- Unregister Server
- Client Tool class: CNetClient - Find servers to connect to
- Create a list of servers
- Connect to server
- Master Server Tool class: Accept connections from servers and clients and tell them about each other
- Accept server connection - register the server
- Accept client connection - send client the server info
Server GUI template
Location: programming\c++\ServerGUI
Files: ServerGUI.cpp,MasterServer.cpp
Status: Working: Needs a few extra features
This template will be used for both single server and the master server. It will contain a tray icon that will be green and turn red when there is a connection. Right clicking the icon will bring up a dialog box containing information. Right clicking the server will provide an exit option followed by an info option.
As a template, it should be designed so that new server types can be easily plugged into it.
Server Dialog
- Server Status
- Connected players
- Total number of connections
- Most connections
- Bytes sent
- Max bytes/sec
Steps until completion(*=complete)
- *Get dialog up
- *Tray icon and make dialog appear when tray icon is clicked
- *Add server and make tray icon change color when a player has connected
- *Add exit when right clicked minimize server properties on exit
Server file format.
Commands
- # Comment
- AddServer IP Port Name OptionalData
- MasterServer IP ClientPort ServerPort Name
Client GUI Class
Location: programming\c++\ClientGUI
Files: ClientGUI.cpp,MasterServer.cpp
Status: Complete
This dialog will use the CNetClient class to obtain a list of severs. It will display the list and allow the player to choose a server.
Polyart.net server listing
Location: polyart.net/server/Servers.php
Location: polyart.net/server/AddServer.php
Location: programming\c++\cvs\polylib
Usage
Servers.php?Game=GameName
AddServer.php?IP=LanIP&Port=ServerPort&Game=GameName
Copyright 2004 © Polyart. All rights reserved.