|
void | sendDisconnectPacket (const char *reason) |
|
virtual bool | canRemoteCreate () |
|
virtual void | onTimedOut () |
|
virtual void | onConnectTimedOut () |
|
virtual void | onDisconnect (const char *reason) |
|
virtual void | onConnectionRejected (const char *reason) |
|
virtual void | onConnectionEstablished (bool isInitiator) |
|
virtual void | handleStartupError (const char *errorString) |
|
virtual void | writeConnectRequest (BitStream *stream) |
|
virtual bool | readConnectRequest (BitStream *stream, const char **errorString) |
|
virtual void | writeConnectAccept (BitStream *stream) |
|
virtual bool | readConnectAccept (BitStream *stream, const char **errorString) |
|
void | connect (const NetAddress *address) |
|
U32 | getNetClassGroup () |
|
void | setSimulatedNetParams (F32 packetLoss, U32 ping) |
|
bool | isConnectionToServer () |
|
bool | isLocalConnection () |
|
bool | isNetworkConnection () |
|
void | setIsConnectionToServer () |
|
void | setIsLocalClientConnection () |
|
void | setNetworkConnection (bool net) |
|
virtual void | setEstablished () |
|
void | setRemoteConnectionObject (NetConnection *connection) |
| Call this if the "connection" is local to this app. This short-circuits the protocol layer. More...
|
|
void | setSequence (U32 connectSequence) |
|
void | setAddressDigest (U32 digest[4]) |
|
void | getAddressDigest (U32 digest[4]) |
|
U32 | getSequence () |
|
void | setProtocolVersion (U32 protocolVersion) |
|
U32 | getProtocolVersion () |
|
F32 | getRoundTripTime () |
|
F32 | getPacketLoss () |
|
void | checkMaxRate () |
|
void | handlePacket (BitStream *stream) |
|
void | processRawPacket (BitStream *stream) |
|
void | handleNotify (bool recvd) |
|
void | handleConnectionEstablished () |
|
void | keepAlive () |
|
const NetAddress * | getNetAddress () |
|
void | setNetAddress (const NetAddress *address) |
|
Net::Error | sendPacket (BitStream *stream) |
|
bool | checkTimeout (U32 time) |
| returns true if the connection timed out More...
|
|
void | checkPacketSend (bool force) |
|
bool | missionPathsSent () const |
|
void | setMissionPathsSent (const bool s) |
|
void | onRemove () |
| Called when the object is removed from the sim. More...
|
|
| NetConnection () |
|
| ~NetConnection () |
|
void | setConnectionState (U32 state) |
|
U32 | getConnectionState () |
|
void | setGhostFrom (bool ghostFrom) |
| Sets whether ghosts transmit from this side of the connection. More...
|
|
void | setGhostTo (bool ghostTo) |
| Sets whether ghosts are allowed from the other side of the connection. More...
|
|
void | setSendingEvents (bool sending) |
| Sets whether this side actually sends the events that are posted to it. More...
|
|
void | setTranslatesStrings (bool xl) |
| Sets whether this connection is capable of translating strings. More...
|
|
void | setNetClassGroup (U32 group) |
| Sets the group of NetClasses this connection traffics in. More...
|
|
bool | isEstablished () |
| Is the connection established? More...
|
|
| DECLARE_CONOBJECT (NetConnection) |
|
virtual PacketNotify * | allocNotify () |
|
| ConnectionProtocol () |
|
void | buildSendPacketHeader (BitStream *bstream, S32 packetType=0) |
|
void | sendPingPacket () |
|
void | sendAckPacket () |
|
void | setConnectionEstablished () |
|
bool | windowFull () |
|
bool | connectionEstablished () |
|
void | setConnectSequence (U32 connectSeq) |
|
| ~SimGroup () |
|
virtual void | addObject (SimObject *) |
| Add an object to the group. More...
|
|
void | addObject (SimObject *, SimObjectId) |
|
void | addObject (SimObject *, const char *name) |
|
virtual void | removeObject (SimObject *) |
| Remove an object from the group. More...
|
|
virtual SimObject * | findObject (const char *name) |
| Find an object in the group. More...
|
|
bool | processArguments (S32 argc, const char **argv) |
| Process constructor options. (ie, new SimObject(1,2,3)) More...
|
|
| DECLARE_CONOBJECT (SimGroup) |
|
| SimSet () |
|
| ~SimSet () |
|
virtual void | onDeleteNotify (SimObject *object) |
|
virtual U32 | getTamlChildCount (void) const |
| Called when Taml attempts to compile a list of children. More...
|
|
virtual SimObject * | getTamlChild (const U32 childIndex) const |
| Called when Taml attempts to compile a list of children. More...
|
|
virtual void | addTamlChild (SimObject *pSimObject) |
| Called when Taml attempts to populate an objects children during a read. More...
|
|
void | callOnChildren (const char *method, S32 argc, const char *argv[], bool executeOnChildGroups=true) |
|
virtual void | write (Stream &stream, U32 tabStop, U32 flags=0) |
|
SimObject * | findObjectByInternalName (const char *internalName, bool searchChildren=false) |
|
virtual bool | writeObject (Stream *stream) |
|
virtual bool | readObject (Stream *stream) |
|
void | lock () |
|
void | unlock () |
|
| DECLARE_CONOBJECT (SimSet) |
|
void | _setVectorAssoc (const char *file, const U32 line) |
|
virtual void | pushObject (SimObject *) |
|
virtual void | popObject () |
| Remove an object from the end of the list. More...
|
|
void | bringObjectToFront (SimObject *obj) |
|
void | pushObjectToBack (SimObject *obj) |
|
SimObject * | front () |
|
SimObject * | first () |
|
SimObject * | last () |
|
bool | empty () |
|
S32 | size () const |
|
iterator | begin () |
|
iterator | end () |
|
value | operator[] (S32 index) |
|
iterator | find (iterator first, iterator last, SimObject *obj) |
|
iterator | find (SimObject *obj) |
|
template<typename T > |
bool | containsType (void) |
|
virtual bool | reOrder (SimObject *obj, SimObject *target=0) |
|
SimObject * | at (S32 index) const |
|
void | deleteObjects (void) |
|
void | clear () |
|
StringTableEntry | getClassNamespace () const |
|
StringTableEntry | getSuperClassNamespace () const |
|
void | setClassNamespace (const char *classNamespace) |
|
void | setSuperClassNamespace (const char *superClassNamespace) |
|
void | pushScriptCallbackGuard (void) |
|
void | popScriptCallbackGuard (void) |
|
S32 | getScriptCallbackGuard (void) |
|
Namespace * | getNamespace () |
| Return the object's namespace. More...
|
|
const char * | tabComplete (const char *prevText, S32 baseLen, bool) |
|
virtual void | dump () |
|
virtual void | dumpClassHierarchy () |
|
SimObject * | clone (const bool copyDynamicFields) |
|
virtual void | copyTo (SimObject *object) |
|
template<typename T > |
bool | isType (void) |
|
virtual bool | handlesConsoleMethod (const char *fname, S32 *routingId) |
|
| DECLARE_CONOBJECT (SimObject) |
|
Notify * | removeNotify (void *ptr, Notify::Type) |
| Remove a notification from the list. More...
|
|
void | deleteNotify (SimObject *obj) |
| Notify an object when we are deleted. More...
|
|
void | clearNotify (SimObject *obj) |
| Notify an object when we are cleared. More...
|
|
void | clearAllNotifications () |
| Remove all notifications for this object. More...
|
|
void | processDeleteNotifies () |
| Send out deletion notifications. More...
|
|
void | registerReference (SimObject **obj) |
|
void | unregisterReference (SimObject **obj) |
|
const char * | getDataField (StringTableEntry slotName, const char *array) |
|
void | setDataField (StringTableEntry slotName, const char *array, const char *value) |
|
const char * | getPrefixedDataField (StringTableEntry fieldName, const char *array) |
|
void | setPrefixedDataField (StringTableEntry fieldName, const char *array, const char *value) |
|
const char * | getPrefixedDynamicDataField (StringTableEntry fieldName, const char *array, const S32 fieldType=-1) |
|
void | setPrefixedDynamicDataField (StringTableEntry fieldName, const char *array, const char *value, const S32 fieldType=-1) |
|
StringTableEntry | getDataFieldPrefix (StringTableEntry fieldName) |
|
U32 | getDataFieldType (StringTableEntry slotName, const char *array) |
|
SimFieldDictionary * | getFieldDictionary () |
|
void | clearDynamicFields (void) |
| Clear all dynamic fields. More...
|
|
void | setCanSaveDynamicFields (bool bCanSave) |
| Set whether fields created at runtime should be saved. Default is true. More...
|
|
bool | getCanSaveDynamicFields (void) const |
| Get whether fields created at runtime should be saved. Default is true. More...
|
|
void | setInternalName (const char *newname) |
|
StringTableEntry | getInternalName () |
| Get the internal of of this control. More...
|
|
virtual bool | save (const char *pcFilePath, bool bOnlySelected=false) |
| Save object as a TorqueScript File. More...
|
|
virtual bool | isMethod (const char *methodName) |
| Check if a method exists in the objects current namespace. More...
|
|
SimObjectId | getId (void) const |
|
StringTableEntry | getIdString (void) const |
|
U32 | getType () const |
|
const StringTableEntry | getName (void) const |
|
void | setId (SimObjectId id) |
|
void | assignName (const char *name) |
|
SimGroup * | getGroup () const |
|
bool | isChildOfGroup (SimGroup *pGroup) |
|
bool | isProperlyAdded () const |
|
bool | isDeleted () const |
|
bool | isRemoved () const |
|
bool | isLocked () |
|
void | setLocked (bool b) |
|
bool | isHidden () |
|
void | setHidden (bool b) |
|
void | setProgenitorFile (const char *pFile) |
|
StringTableEntry | getProgenitorFile (void) const |
|
void | setPeriodicTimerID (const S32 timerID) |
|
S32 | getPeriodicTimerID (void) const |
|
bool | isPeriodicTimerActive (void) const |
|
bool | isSelected () const |
|
bool | isExpanded () const |
|
void | setSelected (bool sel) |
|
void | setExpanded (bool exp) |
|
void | setModDynamicFields (bool dyn) |
|
void | setModStaticFields (bool sta) |
|
| SimObject (const U8 namespaceLinkMask=LinkSuperClassName|LinkClassName) |
|
virtual | ~SimObject () |
|
virtual bool | onAdd () |
| Called when the object is added to the sim. More...
|
|
virtual void | onGroupAdd () |
| Called when the object is added to a SimGroup. More...
|
|
virtual void | onGroupRemove () |
| Called when the object is removed from a SimGroup. More...
|
|
virtual void | onNameChange (const char *name) |
| Called when the object's name is changed. More...
|
|
virtual void | onStaticModified (const char *slotName, const char *newValue=NULL) |
|
virtual void | inspectPreApply () |
|
virtual void | inspectPostApply () |
|
virtual void | onEditorEnable () |
| Called when the editor is activated. More...
|
|
virtual void | onEditorDisable () |
| Called when the editor is deactivated. More...
|
|
bool | registerObject () |
|
bool | registerObject (U32 id) |
|
bool | registerObject (const char *name) |
|
bool | registerObject (const char *name, U32 id) |
|
void | unregisterObject () |
|
void | deleteObject () |
|
bool | addToSet (SimObjectId) |
|
bool | addToSet (const char *) |
|
bool | removeFromSet (SimObjectId) |
|
bool | removeFromSet (const char *) |
|
virtual bool | writeField (StringTableEntry fieldname, const char *value) |
|
virtual void | writeFields (Stream &stream, U32 tabStop) |
|
virtual void | buildFilterList () |
|
void | addFieldFilter (const char *fieldName) |
|
void | removeFieldFilter (const char *fieldName) |
|
void | clearFieldFilters () |
|
bool | isFiltered (const char *fieldName) |
|
void | assignFieldsFrom (SimObject *obj) |
|
void | assignDynamicFieldsFrom (SimObject *obj) |
|
const AbstractClassRep::Field * | findField (StringTableEntry fieldName) const |
| Get a reference to a field by name. More...
|
|
virtual AbstractClassRep * | getClassRep () const |
| Gets the ClassRep. More...
|
|
bool | setField (const char *fieldName, const char *value) |
| Set the value of a field. More...
|
|
virtual | ~ConsoleObject () |
|
const AbstractClassRep::FieldList & | getFieldList () const |
| Get a list of all the fields. This information cannot be modified. More...
|
|
AbstractClassRep::FieldList & | getModifiableFieldList () |
|
bool & | getDynamicGroupExpand () |
|
S32 | getClassId (U32 netClassGroup) const |
|
const char * | getClassName () const |
|
|
enum | GhostConstants { GhostIdBitSize = 12,
MaxGhostCount = 1 << GhostIdBitSize,
GhostLookupTableSize = 1 << GhostIdBitSize,
GhostIndexBitSize = 4
} |
| Some configuration values. More...
|
|
enum | GhostStates {
GhostAlwaysDone,
ReadyForNormalGhosts,
EndGhosting,
GhostAlwaysStarting,
SendNextDownloadRequest,
FileDownloadSizeMessage,
NumConnectionMessages
} |
|
GhostInfo ** | mGhostArray |
| Linked list of ghostInfos ghosted by this side of the connection. More...
|
|
U32 | mGhostZeroUpdateIndex |
| Index in mGhostArray of first ghost with 0 update mask. More...
|
|
U32 | mGhostFreeIndex |
| Index in mGhostArray of first free ghost. More...
|
|
U32 | mGhostsActive |
|
bool | mGhosting |
| Am I currently ghosting objects? More...
|
|
bool | mScoping |
| am I currently scoping objects? More...
|
|
U32 | mGhostingSequence |
| Sequence number describing this ghosting session. More...
|
|
NetObject ** | mLocalGhosts |
|
GhostInfo * | mGhostRefs |
| Allocated array of ghostInfos. Null if ghostFrom is false. More...
|
|
GhostInfo ** | mGhostLookupTable |
| Table indexed by object id to GhostInfo. Null if ghostFrom is false. More...
|
|
SimObjectPtr< NetObject > | mScopeObject |
|
U32 | getGhostsActive () |
|
bool | isGhostingTo () |
| Are we ghosting to someone? More...
|
|
bool | isGhostingFrom () |
| Are we ghosting from someone? More...
|
|
void | ghostOnRemove () |
| Called by onRemove, to shut down the ghost subsystem. More...
|
|
virtual void | doneScopingScene () |
|
void | setScopeObject (NetObject *object) |
| Set the object around which we are currently scoping network traffic. More...
|
|
NetObject * | getScopeObject () |
| Get the object aorund which we are currently scoping network traffic. More...
|
|
void | objectInScope (NetObject *object) |
| Add an object to scope. More...
|
|
void | objectLocalScopeAlways (NetObject *object) |
| Add an object to scope, marking that it should always be scoped to this connection. More...
|
|
void | objectLocalClearAlways (NetObject *object) |
|
NetObject * | resolveGhost (S32 id) |
| Get a NetObject* from a ghost ID (on client side). More...
|
|
NetObject * | resolveObjectFromGhostIndex (S32 id) |
| Get a NetObject* from a ghost index (on the server side). More...
|
|
S32 | getGhostIndex (NetObject *object) |
|
void | ghostPushNonZero (GhostInfo *gi) |
| Move a GhostInfo into the nonzero portion of the list (so that we know to update it). More...
|
|
void | ghostPushToZero (GhostInfo *gi) |
| Move a GhostInfo into the zero portion of the list (so that we know not to update it). More...
|
|
void | ghostPushZeroToFree (GhostInfo *gi) |
| Move a GhostInfo from the zero portion of the list to the free portion. More...
|
|
void | ghostPushFreeToZero (GhostInfo *info) |
| Move a GhostInfo from the free portion of the list to the zero portion. More...
|
|
void | resetGhosting () |
|
void | activateGhosting () |
| Activate ghosting, once it's enabled. More...
|
|
bool | isGhosting () |
| Are we ghosting? More...
|
|
void | detachObject (GhostInfo *info) |
| Begin to stop ghosting an object. More...
|
|
void | setGhostAlwaysObject (NetObject *object, U32 index) |
| Mark an object to be always ghosted. Index is the ghost index of the object. More...
|
|
void | sendConnectionMessage (U32 message, U32 sequence=0, U32 ghostCount=0) |
|
virtual void | handleConnectionMessage (U32 message, U32 sequence, U32 ghostCount) |
|
void | clearGhostInfo () |
|
bool | validateGhostArray () |
|
void | ghostPacketDropped (PacketNotify *notify) |
|
void | ghostPacketReceived (PacketNotify *notify) |
|
void | ghostWritePacket (BitStream *bstream, PacketNotify *notify) |
|
void | ghostReadPacket (BitStream *bstream) |
|
void | freeGhostInfo (GhostInfo *) |
|
void | ghostWriteStartBlock (ResizeBitStream *stream) |
|
void | ghostReadStartBlock (BitStream *stream) |
|
Torque network connection.
Introduction
NetConnection 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:
- Event manager, which is responsible for transmitting NetEvents over the wire. It deals with ensuring that the various types of NetEvents are delivered appropriately, and with notifying the event of its delivery status.
- Move manager, which is responsible for transferring a Move to the server 32 times a second (on the client) and applying it to the control object (on the server).
- Ghost manager, which is responsible for doing scoping calculations (on the server side) and transmitting most-recent ghost information to the client.
- File transfer; it is often the case that clients will lack important files when connecting to a server which is running a mod or new map. This subsystem allows the server to transfer such files to the client.
- Networked String Table; string data can easily soak up network bandwidth, so for efficiency, we implement a networked string table. We can then notify the connection of strings we will reference often, such as player names, and transmit only a tag, instead of the whole string.
- Demo Recording is also implemented in NetConnection. A demo in Torque is a log of the network traffic between client and server; when a NetConnection records a demo, it simply logs this data to a file. When it plays a demo back, it replays the logged data.
- The Connection Database is used to keep track of all the NetConnections; it can be iterated over (for instance, to send an event to all active connections), or queried by address.
On Events
The Event Manager is exposed to the outside world via postNetEvent(), which accepts NetEvents.
- See Also
- NetEvent for a more thorough explanation of how to use events.
On Ghosting and Scoping
Ghosting 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.
- See Also
- NetObject, which is the superclass for ghostable objects, and ShapeBase, which is the base for player and vehicle classes.