Esempio n. 1
0
        public void Send(Creature creature, ISendPacket packet)
        {
            Player player = creature as Player;
            if (player != null)
            {
                if (player.Connection != null)
                    packet.Send(player.Connection);
            }

            creature.VisiblePlayers.Each(p => packet.Send(p.Connection));
        }
Esempio n. 2
0
 public void SendPacketToGuildMembers(ISendPacket packet, Guild guild, Player sender = null)
 {
     lock (guild.MembersLock)
         foreach (
             KeyValuePair <Player, int> guildMember in
             guild.GuildMembers.Where(
                 guildMember => Communication.Global.PlayerService.IsPlayerOnline(guildMember.Key) && !guildMember.Key.Equals(sender)))
         {
             packet.Send(guildMember.Key.Connection);
         }
 }
Esempio n. 3
0
        public void Send(Creature creature, ISendPacket packet)
        {
            Player player = creature as Player;

            if (player != null)
            {
                if (player.Connection != null)
                {
                    packet.Send(player.Connection);
                }
            }

            creature.VisiblePlayers.Each(p => packet.Send(p.Connection));
        }
Esempio n. 4
0
        public bool Send(ISendPacket packet)
        {
            var buffer = packet.Compile();

            if (IsConnected)
            {
                var success = Send(buffer, 0, packet.Length, packet.Name);
                if (!success)
                {
                    Disconnect();
                }
                return(success);
            }
            return(false);
        }
Esempio n. 5
0
        public void SendPacketToPartyMembers(Party party, ISendPacket packet, Player sender = null)
        {
            if (party == null)
            {
                return;
            }

            lock (party.MemberLock)
                foreach (Player member in party.PartyMembers)
                {
                    if (!member.Equals(sender) && Communication.Global.PlayerService.IsPlayerOnline(member))
                    {
                        packet.Send(member.Connection);
                    }
                }
        }
Esempio n. 6
0
 public static void Send(ISendPacket packet)
 {
     if (_ClientNetwork.IsConnected)
     {
         bool success = _ClientNetwork.Send(packet);
         if (!success)
         {
             Disconnect();
         }
     }
 }
Esempio n. 7
0
 public void SendPacketToGuildMembers(ISendPacket packet, Guild guild, Player sender = null)
 {
     lock (guild.MembersLock)
         foreach (
             KeyValuePair<Player, int> guildMember in
                 guild.GuildMembers.Where(
                     guildMember => Communication.Global.PlayerService.IsPlayerOnline(guildMember.Key) && !guildMember.Key.Equals(sender)))
             packet.Send(guildMember.Key.Connection);
 }
Esempio n. 8
0
 public void Send(ISendPacket packet)
 {
     PlayersOnline.Each(player => packet.Send(player.Connection));
 }
Esempio n. 9
0
 public override bool Send(ISendPacket packet)
 {
     if (IsConnected)
     {
         bool success = base.Send(packet);
         if (!success)
         {
             Disconnect();
         }
         return success;
     }
     else
     {
         return false;
     }
 }
Esempio n. 10
0
 public void Send(ISendPacket packet)
 {
     PlayersOnline.Each(player => packet.Send(player.Connection));
 }
Esempio n. 11
0
 public DHCPv6Tester(ISendPacket sendPacket, IExpectedPacket expectedPacket, BaseTester next) : base(sendPacket, expectedPacket, next)
 {
 }
Esempio n. 12
0
        /// <summary>
        /// value type: byte ushort uint ulong string byte[] ushort[] uint[] ulong[] string[]
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="protocolID"></param>
        /// <returns></returns>
        public static BasePacket MakeUniversalPacket(ISendPacket packet, ushort protocolID)
        {
            var         properties = packet.GetType().GetProperties();
            List <byte> dataList   = new List <byte>();

            for (int i = 0; i < properties.Length; i++)
            {
                Type type = properties[i].PropertyType;

                if (type == typeof(byte))
                {
                    dataList.Add((byte)properties[i].GetValue(packet));
                }
                else if (type == typeof(ushort))
                {
                    ushort data = (ushort)properties[i].GetValue(packet);
                    dataList.AddRange(data.ToBytes());
                }
                else if (type == typeof(uint))
                {
                    uint data = (uint)properties[i].GetValue(packet);
                    dataList.AddRange(data.ToBytes());
                }
                else if (type == typeof(ulong))
                {
                    ulong data = (ulong)properties[i].GetValue(packet);
                    dataList.AddRange(data.ToBytes());
                }
                else if (type == typeof(string))
                {
                    string data = (string)properties[i].GetValue(packet);
                    dataList.AddRange(data.ToTBytes());
                }
                else if (type == typeof(byte[]))
                {
                    byte[] data   = (byte[])properties[i].GetValue(packet);
                    int    length = data.Length;
                    if (length > 253)
                    {
                        dataList.Add(253);
                        dataList.AddRange(length.ToBytes());
                        dataList.AddRange(data);
                    }
                    else
                    {
                        dataList.Add((byte)length);
                        for (int k = 0; k < length; k++)
                        {
                            dataList.AddRange(data);
                        }
                    }
                }
                else if (type == typeof(ushort[]))
                {
                    ushort[] data   = (ushort[])properties[i].GetValue(packet);
                    int      length = data.Length;
                    if (length > 253)
                    {
                        dataList.Add(253);
                        dataList.AddRange(length.ToBytes());
                        for (int k = 0; k < length; k++)
                        {
                            dataList.AddRange(data[k].ToBytes());
                        }
                    }
                    else
                    {
                        dataList.Add((byte)length);
                        for (int k = 0; k < length; k++)
                        {
                            dataList.AddRange(data[k].ToBytes());
                        }
                    }
                }
                else if (type == typeof(uint[]))
                {
                    uint[] data   = (uint[])properties[i].GetValue(packet);
                    int    length = data.Length;
                    if (length > 253)
                    {
                        dataList.Add(253);
                        dataList.AddRange(length.ToBytes());
                        for (int k = 0; k < length; k++)
                        {
                            dataList.AddRange(data[k].ToBytes());
                        }
                    }
                    else
                    {
                        dataList.Add((byte)length);
                        for (int k = 0; k < length; k++)
                        {
                            dataList.AddRange(data[k].ToBytes());
                        }
                    }
                }
                else if (type == typeof(ulong[]))
                {
                    ulong[] data   = (ulong[])properties[i].GetValue(packet);
                    int     length = data.Length;
                    if (length > 253)
                    {
                        dataList.Add(253);
                        dataList.AddRange(length.ToBytes());
                        for (int k = 0; k < length; k++)
                        {
                            dataList.AddRange(data[k].ToBytes());
                        }
                    }
                    else
                    {
                        dataList.Add((byte)length);
                        for (int k = 0; k < length; k++)
                        {
                            dataList.AddRange(data[k].ToBytes());
                        }
                    }
                }
                else if (type == typeof(string[]))
                {
                    string[] data   = (string[])properties[i].GetValue(packet);
                    int      length = data.Length;
                    if (length > 253)
                    {
                        dataList.Add(253);
                        dataList.AddRange(length.ToBytes());
                        for (int k = 0; k < length; k++)
                        {
                            dataList.AddRange(data[k].ToXBytes());
                        }
                    }
                    else
                    {
                        dataList.Add((byte)(length));
                        for (int k = 0; k < length; k++)
                        {
                            dataList.AddRange(data[k].ToXBytes());
                        }
                    }
                }
                else
                {
                    Logger.Error($"Unknow type for packet:{protocolID.ToString("x")}, type:{type.Name}");
                }
            }

            return(new BasePacket(protocolID, dataList.ToArray()));
        }
Esempio n. 13
0
        public void SendPacketToPartyMembers(Party party, ISendPacket packet, Player sender = null)
        {
            if (party == null)
                return;

                lock (party.MemberLock)
                    foreach (Player member in party.PartyMembers)
                        if (!member.Equals(sender) && Communication.Global.PlayerService.IsPlayerOnline(member))
                            packet.Send(member.Connection);
        }
Esempio n. 14
0
 public void Send(ISendPacket sendPacket)
 {
     throw new NotImplementedException();
 }
Esempio n. 15
0
 public void Send(ClientSocket serverSocket, ISendPacket iSendPacket)
 {
     iSendPacket.Send(serverSocket);
 }
Esempio n. 16
0
 public BaseTester(ISendPacket sendPacket, IExpectedPacket expectedPacket, BaseTester next)
 {
     this.next           = next;
     this.sendPacket     = sendPacket;
     this.expectedPacket = expectedPacket;
 }