210 likes | 331 Views
By Kenneth C. Finney. 3D Game Programming All in One. Chapter 6 Network. Network. NetworkConnection object handles network GameConnection object links the client to the server (on the server) GameConnection object links the server to the client (on the client). Network. Direct Messaging
E N D
By Kenneth C. Finney 3D Game Programming All in One
Network • NetworkConnection object handles network • GameConnection object links the client to the server (on the server) • GameConnection object links the server to the client (on the client)
Network • Direct Messaging • CommandToServer sends messages from client to the server • There must be a message handler on the server that expects the message • Client needs to know what the server expects (format) • Handler looks like this: function ServerCmdHandlerName()
Network • Direct Messaging • CommandToClient sends messages from server to the client • There must be a message handler on the client that expects the message • Server needs to know what the client expects (format) • Handler looks like this: function ClientCmdHandlerName ()
Network • Direct Messaging • Use for ad hoc messages • Scoring • Synchronization • Setup options • Map cycling • Anything else you can dream up
Network • Triggers • Area triggers • Animation triggers • Weapon state triggers • Player event control triggers
Network • Player Event Control Triggers • AKA “player move event trigger” • Indirect messaging mechanism • Increment/decrement a count on client • Client will notify server in the background • Uses a first-in, first-out (fifo) queue • Maximum 255 events
Network • GameConnection Messages • Negotiate client – server connection process • Use handlers you can override • Time-outs and error messages are built in
Network • Lab: Finding Servers with emaga6 • Exercise the LAN query mode • Explore master server concept • Upgrade Emaga5 to Emaga6 to support network play • Run a game over a network connection • Use$Client::GameTypeQueryand$Client::MissionTypeQueryas filter variables
Network • control/client/interfaces/serverscreen • GUI module • Defines buttons, text labels, and scroll controls • The screen is used to display servers to be selected by the player
Network • control/client/misc/serverscreen • Control script for serverscreen GUI • Define behavior of GUI controls • Show how to initiate a client's connection to a server • Show how to query a server for information
Network • Dedicated Server • Make changes to: • root main module • control/main.cs module • control/initialize.cs module
Network • Testing emaga6 • Run dedicated server • Then run client • In the client look for the server and join it • Use emaga6 to also test direct messaging
Summary • Use direct messaging for ad hoc messages: CommandToServer() and CommandToClient() and their handler counterparts: ServerCmd...() and ClientCmd...() • Player Event Control Triggers (PECTs) are used to trigger movement or other action events • PECTs use a FIFO (first-in, first-out) queue for posted event—they operate like a "fire-and-forget" system
Summary • There are six PECT queues: $mvTriggerCount0 to $mvTriggerCount5— each can hold 255 events • GameConnection messages handle server-client synchronization and game update issues • Torque has built-in capabilities for locating master servers from which to find a list of available game servers • Torque's networking works equally well on LANs and the Internet