#include <ConnectionManager.h>
Public Member Functions | |
| ConnectionManager () | |
| ~ConnectionManager () | |
| virtual void | init () |
| Initialize this instance. | |
| virtual void | reset () |
| Take this instance back to the initial state. | |
| virtual void | update (Bool isInGame) |
| Service the Connections being managed by this instance. | |
| void | updateRunAhead (Int oldRunAhead, Int frameRate, Bool didSelfSlug, Int nextExecutionFrame) |
| Update the run ahead value. If we are the current packet router, issue the command. | |
| void | attachTransport (Transport *transport) |
| void | parseUserList (const GameInfo *game) |
| void | sendChat (UnicodeString text, Int playerMask, UnsignedInt executionFrame) |
| void | sendDisconnectChat (UnicodeString text) |
| void | sendLocalCommand (NetCommandMsg *msg, UnsignedByte relay=0xff) |
| Send command to the players specified in the relay, goes through packet router. | |
| void | sendLocalCommandDirect (NetCommandMsg *msg, UnsignedByte relay) |
| Send command directly to the players specified, doesn't go through packet router. | |
| void | sendLocalGameMessage (GameMessage *msg, UnsignedInt frame) |
| void | sendCommand (NetCommandMsg *msg) |
| Bool | allCommandsReady (UnsignedInt frame, Bool justTesting=FALSE) |
| void | handleAllCommandsReady (void) |
| NetCommandList * | getFrameCommandList (UnsignedInt frame) |
| void | determineRouterFallbackPlan () |
| void | zeroFrames (UnsignedInt startingFrame, UnsignedInt numFrames) |
| void | destroyGameMessages () |
| void | setLocalAddress (UnsignedInt ip, UnsignedInt port) |
| void | initTransport () |
| void | processFrameTick (UnsignedInt frame) |
| void | handleLocalPlayerLeaving (UnsignedInt frame) |
| void | sendFile (AsciiString path, UnsignedByte playerMask, UnsignedShort commandID) |
| UnsignedShort | sendFileAnnounce (AsciiString path, UnsignedByte playerMask) |
| Int | getFileTransferProgress (Int playerID, AsciiString path) |
| Bool | areAllQueuesEmpty (void) |
| UnsignedInt | getLocalPlayerID () |
| UnicodeString | getPlayerName (Int playerNum) |
| Int | getNumPlayers () |
| UnsignedInt | getPacketRouterFallbackSlot (Int packetRouterNumber) |
| Returns the slot of the given packet router number in the fallback plan. | |
| UnsignedInt | getPacketRouterSlot () |
| Returns the current packet router's slot. | |
| PlayerLeaveCode | disconnectPlayer (Int slot) |
| Disconnect this player immediately. This should only be called by the disconnect manager. | |
| void | disconnectLocalPlayer () |
| Does whatever is necessary to get TheNetwork to realize that it should be leaving the game now. | |
| void | quitGame () |
| Disconnect from the game RIGHT NOW!! Tell everyone else we are disconnecting. | |
| void | voteForPlayerDisconnect (Int slot) |
| Register a vote for a player to be disconnected. | |
| void | resendPendingCommands () |
| Resend the pending commands to the packet router. | |
| void | setFrameGrouping (time_t frameGrouping) |
| Set the number of frames that are grouped together into packets. | |
| PlayerLeaveCode | processPlayerLeave (NetPlayerLeaveCommandMsg *msg) |
| Bool | canILeave () |
| Returns true if the local player is allowed to leave. | |
| Real | getIncomingBytesPerSecond (void) |
| Real | getIncomingPacketsPerSecond (void) |
| Real | getOutgoingBytesPerSecond (void) |
| Real | getOutgoingPacketsPerSecond (void) |
| Real | getUnknownBytesPerSecond (void) |
| Real | getUnknownPacketsPerSecond (void) |
| UnsignedInt | getPacketArrivalCushion (void) |
| UnsignedInt | getMinimumCushion () |
| void | flushConnections () |
| void | processChat (NetChatCommandMsg *msg) |
| void | updateLoadProgress (Int progress) |
| void | loadProgressComplete (void) |
| void | sendTimeOutGameStart (void) |
| Bool | isPacketRouter (void) |
| Bool | isPlayerConnected (Int playerID) |
| void | notifyOthersOfCurrentFrame (Int frame) |
| void | sendFrameDataToPlayer (UnsignedInt playerID, UnsignedInt startingFrame) |
| void | sendSingleFrameToPlayer (UnsignedInt playerID, UnsignedInt frame) |
| void | notifyOthersOfNewFrame (UnsignedInt frame) |
| UnsignedInt | getNextPacketRouterSlot (UnsignedInt playerID) |
| returns the packet router player that comes after the given player. | |
| Int | getAverageFPS (void) |
| Int | getSlotAverageFPS (Int slot) |
| UnsignedInt | getPingFrame () |
| Int | getPingsSent () |
| Int | getPingsRecieved () |
Definition at line 50 of file ConnectionManager.h.
| ConnectionManager::ConnectionManager | ( | void | ) |
Le constructor
Definition at line 128 of file ConnectionManager.cpp.
| ConnectionManager::~ConnectionManager | ( | void | ) |
Le destructor.
Definition at line 65 of file ConnectionManager.cpp.
| Bool ConnectionManager::allCommandsReady | ( | UnsignedInt | frame, |
| Bool | justTesting = FALSE ) |
Returns true if all the commands for the given frame are ready to be executed.
Definition at line 1552 of file ConnectionManager.cpp.
| Bool ConnectionManager::areAllQueuesEmpty | ( | void | ) |
Definition at line 976 of file ConnectionManager.cpp.
| void ConnectionManager::attachTransport | ( | Transport * | transport | ) |
Definition at line 305 of file ConnectionManager.cpp.
| Bool ConnectionManager::canILeave | ( | ) |
Returns true if the local player is allowed to leave.
Definition at line 991 of file ConnectionManager.cpp.
| void ConnectionManager::destroyGameMessages | ( | ) |
Destroy any game messages that are left over due to the run ahead.
Definition at line 329 of file ConnectionManager.cpp.
| void ConnectionManager::determineRouterFallbackPlan | ( | ) |
| void ConnectionManager::disconnectLocalPlayer | ( | ) |
Does whatever is necessary to get TheNetwork to realize that it should be leaving the game now.
Definition at line 1792 of file ConnectionManager.cpp.
| PlayerLeaveCode ConnectionManager::disconnectPlayer | ( | Int | slot | ) |
Disconnect this player immediately. This should only be called by the disconnect manager.
Definition at line 1697 of file ConnectionManager.cpp.
| void ConnectionManager::flushConnections | ( | ) |
Takes all the commands that are ready to send and sends them right now.
Definition at line 1805 of file ConnectionManager.cpp.
| Int ConnectionManager::getAverageFPS | ( | void | ) |
Definition at line 2297 of file ConnectionManager.cpp.
| Int ConnectionManager::getFileTransferProgress | ( | Int | playerID, |
| AsciiString | path ) |
Definition at line 2212 of file ConnectionManager.cpp.
| NetCommandList * ConnectionManager::getFrameCommandList | ( | UnsignedInt | frame | ) |
Only call this after making sure that all the commands are there for this frame. After calling this the commands for this frame will be removed from the connection.
BGC - To account for the case where the host disconnects without sending the same commands to all players, we now have to keep around the last 'run ahead' frames so we can potentially send those commands to the other players in the game so they can catch up.
Definition at line 1613 of file ConnectionManager.cpp.
| Real ConnectionManager::getIncomingBytesPerSecond | ( | void | ) |
Return the number of incoming bytes per second averaged over 30 sec.
Definition at line 2000 of file ConnectionManager.cpp.
| Real ConnectionManager::getIncomingPacketsPerSecond | ( | void | ) |
Return the number of incoming packets per second averaged over the last 30 sec.
Definition at line 2011 of file ConnectionManager.cpp.
| UnsignedInt ConnectionManager::getLocalPlayerID | ( | ) |
Definition at line 1837 of file ConnectionManager.cpp.
| UnsignedInt ConnectionManager::getMinimumCushion | ( | ) |
Definition at line 1395 of file ConnectionManager.cpp.
| UnsignedInt ConnectionManager::getNextPacketRouterSlot | ( | UnsignedInt | playerID | ) |
returns the packet router player that comes after the given player.
Definition at line 2412 of file ConnectionManager.cpp.
| Int ConnectionManager::getNumPlayers | ( | ) |
Definition at line 2237 of file ConnectionManager.cpp.
| Real ConnectionManager::getOutgoingBytesPerSecond | ( | void | ) |
Return the number of outgoing bytes per second averaged over the last 30 sec.
Definition at line 2022 of file ConnectionManager.cpp.
| Real ConnectionManager::getOutgoingPacketsPerSecond | ( | void | ) |
Return the number of outgoing packets per second averaged over the last 30 sec.
Definition at line 2033 of file ConnectionManager.cpp.
| UnsignedInt ConnectionManager::getPacketArrivalCushion | ( | void | ) |
Return the smallest packet arrival cushion since this was last called.
Definition at line 2067 of file ConnectionManager.cpp.
| UnsignedInt ConnectionManager::getPacketRouterFallbackSlot | ( | Int | packetRouterNumber | ) |
Returns the slot of the given packet router number in the fallback plan.
Definition at line 965 of file ConnectionManager.cpp.
| UnsignedInt ConnectionManager::getPacketRouterSlot | ( | ) |
Returns the current packet router's slot.
Definition at line 972 of file ConnectionManager.cpp.
| UnsignedInt ConnectionManager::getPingFrame | ( | ) |
Definition at line 285 of file ConnectionManager.cpp.
| Int ConnectionManager::getPingsRecieved | ( | ) |
Definition at line 295 of file ConnectionManager.cpp.
| Int ConnectionManager::getPingsSent | ( | ) |
Definition at line 290 of file ConnectionManager.cpp.
| UnicodeString ConnectionManager::getPlayerName | ( | Int | playerNum | ) |
Definition at line 1841 of file ConnectionManager.cpp.
Definition at line 2302 of file ConnectionManager.cpp.
| Real ConnectionManager::getUnknownBytesPerSecond | ( | void | ) |
Return the number of bytes not from generals clients received per second averaged over the last 30 sec.
Definition at line 2045 of file ConnectionManager.cpp.
| Real ConnectionManager::getUnknownPacketsPerSecond | ( | void | ) |
Return the number ov packets not from generals clients received per second averaged over the last 30 sec.
Definition at line 2056 of file ConnectionManager.cpp.
| void ConnectionManager::handleAllCommandsReady | ( | void | ) |
Definition at line 1598 of file ConnectionManager.cpp.
| void ConnectionManager::handleLocalPlayerLeaving | ( | UnsignedInt | frame | ) |
The local player is leaving. Tell the local player as well as the other players to remove this player at the specified frame.
Definition at line 999 of file ConnectionManager.cpp.
|
virtual |
Initialize this instance.
Initialize the connection manager and any subsystems.
Definition at line 147 of file ConnectionManager.cpp.
| void ConnectionManager::initTransport | ( | ) |
Initialize the transport object
Definition at line 1437 of file ConnectionManager.cpp.
| Bool ConnectionManager::isPacketRouter | ( | void | ) |
Definition at line 2292 of file ConnectionManager.cpp.
Definition at line 300 of file ConnectionManager.cpp.
| void ConnectionManager::loadProgressComplete | ( | void | ) |
Definition at line 2264 of file ConnectionManager.cpp.
| void ConnectionManager::notifyOthersOfCurrentFrame | ( | Int | frame | ) |
Definition at line 2327 of file ConnectionManager.cpp.
| void ConnectionManager::notifyOthersOfNewFrame | ( | UnsignedInt | frame | ) |
Definition at line 2351 of file ConnectionManager.cpp.
| void ConnectionManager::parseUserList | ( | const GameInfo * | game | ) |
Take a user list and make connections and frame data manager objects for each of the players. For now, this is also how we'll determine the packet router fallback plan.
Definition at line 1855 of file ConnectionManager.cpp.
| void ConnectionManager::processChat | ( | NetChatCommandMsg * | msg | ) |
Definition at line 639 of file ConnectionManager.cpp.
| void ConnectionManager::processFrameTick | ( | UnsignedInt | frame | ) |
The commands for the given frame are all ready, time to send out our command count for that frame.
Definition at line 1402 of file ConnectionManager.cpp.
| PlayerLeaveCode ConnectionManager::processPlayerLeave | ( | NetPlayerLeaveCommandMsg * | msg | ) |
A player has just left our game. Delete their connection and frame data manager. return codes are: PLAYERLEAVECODE_UNKNOWN - player didn't have a valid slot number. PLAYERLEAVECODE_CLIENT - someone in the game that wasn't us or the packet router. PLAYERLEAVECODE_LOCAL - We are leaving the game, we could also be the packet router. PLAYERLEAVECODE_PACKETROUTER - The packet router left the game.
If we are leaving and are also the packet router, it will return the PLAYERLEAVECODE_LOCAL return code.
Definition at line 931 of file ConnectionManager.cpp.
| void ConnectionManager::quitGame | ( | ) |
Disconnect from the game RIGHT NOW!! Tell everyone else we are disconnecting.
Definition at line 1772 of file ConnectionManager.cpp.
| void ConnectionManager::resendPendingCommands | ( | ) |
Resend the pending commands to the packet router.
Definition at line 1823 of file ConnectionManager.cpp.
|
virtual |
Take this instance back to the initial state.
Reset the connection manager and any subsystems.
Definition at line 221 of file ConnectionManager.cpp.
| void ConnectionManager::sendChat | ( | UnicodeString | text, |
| Int | playerMask, | ||
| UnsignedInt | executionFrame ) |
Definition at line 2073 of file ConnectionManager.cpp.
| void ConnectionManager::sendCommand | ( | NetCommandMsg * | msg | ) |
| void ConnectionManager::sendDisconnectChat | ( | UnicodeString | text | ) |
Definition at line 2093 of file ConnectionManager.cpp.
| void ConnectionManager::sendFile | ( | AsciiString | path, |
| UnsignedByte | playerMask, | ||
| UnsignedShort | commandID ) |
Definition at line 2143 of file ConnectionManager.cpp.
| UnsignedShort ConnectionManager::sendFileAnnounce | ( | AsciiString | path, |
| UnsignedByte | playerMask ) |
Definition at line 2105 of file ConnectionManager.cpp.
| void ConnectionManager::sendFrameDataToPlayer | ( | UnsignedInt | playerID, |
| UnsignedInt | startingFrame ) |
Definition at line 2369 of file ConnectionManager.cpp.
| void ConnectionManager::sendLocalCommand | ( | NetCommandMsg * | msg, |
| UnsignedByte | relay = 0xff ) |
Send command to the players specified in the relay, goes through packet router.
This is a NetCommandMsg that originated on the local computer. Send this to everyone specified in the relay field. Commands sent in this way go through the packet router.
Definition at line 1474 of file ConnectionManager.cpp.
| void ConnectionManager::sendLocalCommandDirect | ( | NetCommandMsg * | msg, |
| UnsignedByte | relay ) |
Send command directly to the players specified, doesn't go through packet router.
This is a NetCommandMsg that originated on the local computer. Send this to everyone specified in the relay field. Commands sent in this way do not go through the packet router.
Definition at line 1524 of file ConnectionManager.cpp.
| void ConnectionManager::sendLocalGameMessage | ( | GameMessage * | msg, |
| UnsignedInt | frame ) |
This is where the commands from the local client are sent to the other clients in the game. This is also where the local commands are put into the frame data for future execution.
Definition at line 1454 of file ConnectionManager.cpp.
| void ConnectionManager::sendSingleFrameToPlayer | ( | UnsignedInt | playerID, |
| UnsignedInt | frame ) |
Definition at line 2377 of file ConnectionManager.cpp.
| void ConnectionManager::sendTimeOutGameStart | ( | void | ) |
Definition at line 2278 of file ConnectionManager.cpp.
| void ConnectionManager::setFrameGrouping | ( | time_t | frameGrouping | ) |
Set the number of frames that are grouped together into packets.
Definition at line 1633 of file ConnectionManager.cpp.
| void ConnectionManager::setLocalAddress | ( | UnsignedInt | ip, |
| UnsignedInt | port ) |
Set the local address.
Definition at line 1428 of file ConnectionManager.cpp.
|
virtual |
Service the Connections being managed by this instance.
ConnectionManager::update Update the connections. Tell them to do the receive and send. Also relay commands to their final destinations as necessary.
Definition at line 1156 of file ConnectionManager.cpp.
| void ConnectionManager::updateLoadProgress | ( | Int | progress | ) |
Definition at line 2250 of file ConnectionManager.cpp.
| void ConnectionManager::updateRunAhead | ( | Int | oldRunAhead, |
| Int | frameRate, | ||
| Bool | didSelfSlug, | ||
| Int | nextExecutionFrame ) |
Update the run ahead value. If we are the current packet router, issue the command.
Definition at line 1213 of file ConnectionManager.cpp.
| void ConnectionManager::voteForPlayerDisconnect | ( | Int | slot | ) |
Register a vote for a player to be disconnected.
Definition at line 2231 of file ConnectionManager.cpp.
| void ConnectionManager::zeroFrames | ( | UnsignedInt | startingFrame, |
| UnsignedInt | numFrames ) |
zero out the command counts for the given frames. Presently this is used for the start of a game since there won't be any commands for the first few frames due to runahead.
Definition at line 317 of file ConnectionManager.cpp.