Beispiel #1
0
        private void HandleGamePacket(object sender, PacketEventArgs e)
        {
            INetNode node = (INetNode)sender;

            if (e.Type == PacketType.Connect)
            {
                if (e.Data.Length != 0)
                {
                    return;
                }
                byte[] data = new byte [8];
                BitConv.ToInt32(data, 0, nodes.IndexOf(node));
                BitConv.ToInt32(data, 4, nodes.Count);
                node.SendPacket(PacketType.Accepted, data);
            }
            else if (e.Type == PacketType.DoomData)
            {
                if (e.Data.Length < 4)
                {
                    return;
                }
                int nodeid = BitConv.FromInt32(e.Data, 0);
                if (nodeid < 0 || nodeid >= nodes.Count)
                {
                    return;
                }
                byte[] data = new byte [e.Data.Length];
                BitConv.ToInt32(data, 0, nodes.IndexOf(node));
                Array.Copy(e.Data, 4, data, 4, e.Data.Length - 4);
                nodes[nodeid].SendPacket(PacketType.DoomData, data);
            }
        }
Beispiel #2
0
        private void HandleJoinPacket(object sender, PacketEventArgs e)
        {
            INetNode node = (INetNode)sender;

            if (e.Type == PacketType.Connect)
            {
                node.SendPacket(PacketType.Waiting, new byte [0]);
            }
        }