Пример #1
0
        /// <summary>
        ///     Sends a packet.
        /// </summary>
        /// <param name="packet">
        ///     The packet to send.
        /// </param>
        /// <param name="targetNetworkId">
        ///     The target to send the packet to.
        /// </param>
        public static void SendPacket(Packet packet, int targetNetworkId)
        {
            // Make packet not finalize the data, then pass the unencrypted written packet to PluginDataPacket
            // which will append the PluginData header and target network id
            packet.FinalizePacket = false;
            packet.Send(client);

            // Restore finalize packet in case developer reuses it
            packet.FinalizePacket = true;

            var pluginDataPacket = new PluginDataPacket(packet.Message, targetNetworkId);

            pluginDataPacket.Send(client);
        }
Пример #2
0
        /// <summary>
        ///     Registers the packet, which will be called when a packet is received with the header.
        /// </summary>
        /// <param name="packet">
        ///     The packet.
        /// </param>
        /// <returns>
        ///     <c>false</c> if there was a packet registered with the same header and the packet was not added, <c>true</c>
        ///     if the packet was added successfully
        /// </returns>
        public static bool RegisterIncomingPacket(Packet packet)
        {
            var header = packet.Header;

            // Check if a packet with the same header is already registered
            var noError = !BuiltInPackets.Select(x => x.Header).Any(x => x.Equals(header));

            if (RegisteredPackets.Select(x => x.Header).Any(x => x.Equals(header)))
            {
                noError = false;
            }

            if (noError)
            {
                // No collisions, add packet
                RegisteredPackets.Add(packet);
            }
            else
            {
                Notifications.AddNotification("Error loading a plugin for LeagueSharp.Live", 5000);
            }

            return(noError);
        }
Пример #3
0
        /// <summary>
        ///     Sends a packet.
        /// </summary>
        /// <param name="packet">
        ///     The packet to send.
        /// </param>
        /// <param name="targetNetworkId">
        ///     The target to send the packet to.
        /// </param>
        public static void SendPacket(Packet packet, int targetNetworkId)
        {
            // Make packet not finalize the data, then pass the unencrypted written packet to PluginDataPacket
            // which will append the PluginData header and target network id
            packet.FinalizePacket = false;
            packet.Send(client);

            // Restore finalize packet in case developer reuses it
            packet.FinalizePacket = true;

            var pluginDataPacket = new PluginDataPacket(packet.Message, targetNetworkId);
            pluginDataPacket.Send(client);
        }
Пример #4
0
        /// <summary>
        ///     Registers the packet, which will be called when a packet is received with the header.
        /// </summary>
        /// <param name="packet">
        ///     The packet.
        /// </param>
        /// <returns>
        ///     <c>false</c> if there was a packet registered with the same header and the packet was not added, <c>true</c>
        ///     if the packet was added successfully
        /// </returns>
        public static bool RegisterIncomingPacket(Packet packet)
        {
            var header = packet.Header;

            // Check if a packet with the same header is already registered
            var noError = !BuiltInPackets.Select(x => x.Header).Any(x => x.Equals(header));
            if (RegisteredPackets.Select(x => x.Header).Any(x => x.Equals(header)))
            {
                noError = false;
            }

            if (noError)
            {
                // No collisions, add packet
                RegisteredPackets.Add(packet);
            }
            else
            {
                Notifications.AddNotification("Error loading a plugin for LeagueSharp.Live", 5000);
            }

            return noError;
        }