public void TransmitStream(BKSystem.IO.BitStream data, int player)
{
if (m_clients[player] != null && m_clients[player].Connected)
{
// Pad the data by 1 bit ???
data.Write(0);
// Send how large the data is in the first 32 bits
byte[] sendData = data.ToByteArray();
int sendLength = IPAddress.HostToNetworkOrder(sendData.Length);
byte[] lengthData = BitConverter.GetBytes(sendLength);
// Choose the stream to use
NetworkStream stream;
stream = m_clients[player].GetStream();
stream.Flush();
stream.Write(lengthData, 0, lengthData.Length);
//Debug.Log("Sending " + sendData.Length + " bytes to player " + player);
// Then send the data
stream.Write(sendData, 0, sendData.Length);
}
else
{
Debug.LogWarning("Attempting to transmit data while disconnected");
}
}