CHAPTER 8 ■ NETWORKING IN XNA 3.0
614
8-4. Send/Receive Data Over the Network
The Problem
Creating and joining a network session is one thing, but what good is a network session if
you’re not sending and receiving any data?
The Solution
When the player is connected to the session, you can store all the data you want to send in a
PacketWriter stream. Once this has been done, you can send this PacketWriter to all players in
the session using the LocalNetworkPlayer.SendData method.
Before receiving any data for a player on the local machine, you should check whether the
LocalNetworkGamer.IsDataAvailable flag is set to true, which indicates data has been received
and is ready to be processed.
As long as this flag is true, you should call the LocalNetworkGamer.ReceiveData ...