Exemple #1
0
        void Tcp_PacketReceived(byte packetType, Networking.BinaryWrapper reader, System.Net.IPEndPoint endPoint)
        {
            textBox2.Text += "(DEBUG: Client: Received TCP "+packetType.ToString()+")"+Environment.NewLine;

            if (packetType == Networking.ClientPacketTypeBase.ConnectionAck)
            {
                client.Tcp.NetStreamBinary.Write(Networking.PacketTypeBase.EndOfMessage);
            }
            else if (packetType == MyClientPackets.ClientChat)
            {
                var player = client.Players[reader.ReadInt()];
                textBox2.Text += player.Name+": " + Networking.StringWriter.Read(reader)+Environment.NewLine;
            }
            else if (packetType == Networking.ClientPacketTypeBase.PlayerData)
            {
                foreach (var p in client.Players)
                {
                    if (listBox1.Items.Count <= p.Index)
                        listBox1.Items.Add("");

                    if (!p.Active)
                        listBox1.Items[p.Index] = "(Disconnected)";
                    else
                        listBox1.Items[p.Index] = p.Name;
                }
            }
        }