LocalNetworkGamer.ReceiveData Method

Reads the next incoming packet.

Overload List

Name Description
LocalNetworkGamer.ReceiveData (Byte[], Int32, NetworkGamer) Reads the next incoming packet using the specified values.
LocalNetworkGamer.ReceiveData (Byte[], NetworkGamer) Reads the next incoming packet using the specified values.
LocalNetworkGamer.ReceiveData (PacketReader, NetworkGamer) Reads the next incoming packet and copies the packet data into the specified reader object.

Example

Be sure to call ReceiveData for all incoming data for all local gamers, even if the data is to be discarded. Any time data is sent to a local network gamer, the incoming data queue will grow until the data is read. If the data is not read using ReceiveData the performance of the application will degrade as the data queue grows in size.

foreach (LocalNetworkGamer gamer in session.LocalGamers)
{
    // Keep reading while packets are available.
    while (gamer.IsDataAvailable)
    {
        NetworkGamer sender;

        // Read a single packet.
        gamer.ReceiveData(packetReader, out sender);
        // Discard the data, or use packetReader.Read* to process the data.
    }
    gamer.SendData(packetWriter, SendDataOptions.None);
    
}

See Also

Tasks

Receiving Network Data

Reference

LocalNetworkGamer Class
LocalNetworkGamer Members
Microsoft.Xna.Framework.Net Namespace