Exemplo n.º 1
0
        public void Send(GameEvent.GameEvent willSend)
        {
            byte[] data = willSend.packMe();

            byte[] bytes = new byte[(data.Length + 2*sizeof(int))];

            BinaryWriter writer = new BinaryWriter(new MemoryStream(bytes));
            writer.Write((data.Length + 1 * sizeof(int)));
            writer.Write((int)willSend.type);
            for (int i = 0; i < data.Length; i++)
                writer.Write(data[i]);
            writer.Close();

            foreach (NetworkStream stream in streams)
            {
                stream.Write(bytes, 0, bytes.Length);
                stream.Flush();
            }
        }