![]() TGE Version 1.5.2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
NetConnection Class Reference#include <netConnection.h>
Inheritance diagram for NetConnection: ![]() Detailed DescriptionTorque network connection.
IntroductionNetConnection is the glue that binds a networked Torque game together. It combines the low-level notify protocol implemented in ConnectionProtocol with a SimGroup to provide a powerful basis for implementing a multiplayer game protocol.On top of this basis it implements several distinct subsystems:
On EventsThe Event Manager is exposed to the outside world via postNetEvent(), which accepts NetEvents.
On Ghosting and ScopingGhosting is the most complex, and most powerful, part of Torque's networking capabilities. It allows the information sent to clients to be very precisely matched to what they need, so that no excess bandwidth is wasted. The control object's onCameraScopeQuery() is called, to determine scoping information for the client; then objects which are in scope are then transmitted to the client, prioritized by the results of their getPriority() method.There is a cap on the maximum number of ghosts; ghost IDs are currently sent via a 10-bit field, ergo, there is a cap of 1024 objects ghosted per client. This can be easily raised; see the GhostConstants enum. Each object ghosted is assigned a ghost ID; the client is _only_ aware of the ghost ID. This acts to enhance game security, as it becomes difficult to map objects from one connection to another, or to reliably identify objects from ID alone. IDs are also reassigned based on need, making it hard to track objects that have fallen out of scope (as any object which the player shouldn't see would). resolveGhost() is used on the client side, and resolveObjectFromGhostIndex() on the server side, to turn ghost IDs into object references. The NetConnection is a SimGroup. On the client side, it contains all the objects which have been ghosted to that client. On the server side, it is empty; it can be used (typically in script) to hold objects related to the connection. For instance, you might place an observation camera in the NetConnnection. In both cases, when the connection is destroyed, so are the contained objects.
Member Typedef Documentation
Member Enumeration Documentation
Constructor & Destructor Documentation
Member Function Documentation
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Call this if the "connection" is local to this app. This short-circuits the protocol layer.
Implements ConnectionProtocol.
Reimplemented from ConnectionProtocol.
Implements ConnectionProtocol.
Implements ConnectionProtocol.
Implements ConnectionProtocol.
Implements ConnectionProtocol.
Find a NetConnection, if any, with the specified address.
returns true if the connection timed out
Register global constant variables and do other one-time initialization tasks in a subclass of ConsoleObject.
Reimplemented from ConsoleObject. Reimplemented in GameConnection.
Called when the object is removed from the sim.
Reimplemented from SimGroup. Reimplemented in GameConnection.
Sets whether ghosts transmit from this side of the connection.
Sets whether ghosts are allowed from the other side of the connection.
Sets whether this side actually sends the events that are posted to it.
Sets whether this connection is capable of translating strings.
Sets the group of NetClasses this connection traffics in.
Is the connection established?
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Post an event to this connection.
Are we ghosting to someone?
Are we ghosting from someone?
Called by onRemove, to shut down the ghost subsystem.
Called when we're done with normal scoping. This gives subclasses a chance to shove things into scope, such as the results of a sensor network calculation, that would otherwise be awkward to add. Reimplemented in GameConnection. Set the object around which we are currently scoping network traffic.
Get the object aorund which we are currently scoping network traffic.
Add an object to scope, marking that it should always be scoped to this connection.
Mark an object that is being ghosted as not always needing to be scoped. This undoes objectLocalScopeAlways(), but doesn't immediately flush it from scope. Instead, the standard scoping mechanisms will clear it from scope when it is appropos to do so. Get a NetObject* from a ghost ID (on client side).
Get a NetObject* from a ghost index (on the server side).
Get the ghost index corresponding to a given NetObject. This is only meaningful on the server side.
Stop all ghosting activity and inform the other side about this. Turns off ghosting.
Activate ghosting, once it's enabled.
Are we ghosting?
Mark an object to be always ghosted. Index is the ghost index of the object.
Send ghost connection handshake message. As part of the ghoost connection process, extensive hand-shaking must be performed. This is done by passing ConnectionMessageEvents; this is a helper function to more effectively perform this task. Messages are dealt with by handleConnectionMessage().
Handle message from sendConnectionMessage(). This is called to handle messages sent via sendConnectionMessage.
Reimplemented in GameConnection.
Start sending the specified file over the link.
Called when we receive a FileChunkEvent.
Get the next file...
Post the next FileChunkEvent.
This is part of the file transfer logic; basically, we call this every time we finish downloading new files. It attempts to load the GhostAlways objects; if they fail, it marks an error and we have chance to retry.
Reimplemented in GameConnection.
Reimplemented in GameConnection.
Friends And Related Function Documentation
Field Documentation
Next item in list.
Previous item in list.
Head of list.
The NetClassGroup of this connection.
Reimplemented from ConnectionProtocol.
If we're doing a "short circuited" connection, this stores a pointer to the other side.
number of connection messages we've sent.
State of the connection, from NetConnectionState.
Head of packet notify list.
Tail of packet notify list.
Linked list of ghostInfos ghosted by this side of the connection.
Index in mGhostArray of first ghost with 0 update mask.
Index in mGhostArray of first free ghost.
am I currently scoping objects?
Sequence number describing this ghosting session.
Local ghost for remote object. mLocalGhosts pointer is NULL if mGhostTo is false
Allocated array of ghostInfos. Null if ghostFrom is false.
Table indexed by object id to GhostInfo. Null if ghostFrom is false.
The object around which we are scoping this connection. This is usually the player object, or a related object, like a vehicle that the player is driving.
List of files missing for this connection. The currently downloading file is always first in the list (ie, [0]).
Stream for currently uploading file (if any).
Storage for currently downloading file.
Size of currently downloading file in bytes.
Our position in the currently downloading file in bytes.
Number of files we have downloaded.
Error storage for file transfers.
List of objects to ghost-always.
|