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)); }
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); } }
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)); }
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); }
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); } } }
public static void Send(ISendPacket packet) { if (_ClientNetwork.IsConnected) { bool success = _ClientNetwork.Send(packet); if (!success) { Disconnect(); } } }
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); }
public void Send(ISendPacket packet) { PlayersOnline.Each(player => packet.Send(player.Connection)); }
public override bool Send(ISendPacket packet) { if (IsConnected) { bool success = base.Send(packet); if (!success) { Disconnect(); } return success; } else { return false; } }
public DHCPv6Tester(ISendPacket sendPacket, IExpectedPacket expectedPacket, BaseTester next) : base(sendPacket, expectedPacket, next) { }
/// <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())); }
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); }
public void Send(ISendPacket sendPacket) { throw new NotImplementedException(); }
public void Send(ClientSocket serverSocket, ISendPacket iSendPacket) { iSendPacket.Send(serverSocket); }
public BaseTester(ISendPacket sendPacket, IExpectedPacket expectedPacket, BaseTester next) { this.next = next; this.sendPacket = sendPacket; this.expectedPacket = expectedPacket; }