Example #1
0
        /// <summary>
        /// Sends a packet to the game server.
        /// </summary>
        /// <param name="type">The type of packet to send.</param>
        /// <param name="data">The packet data (Not the packet header).</param>
        public void SendPacket(GameServerOutPacketType type, byte[] data)
        {
            GameClientPacket packet = new GameClientPacket();

            packet.Id   = type;
            packet.Data = data;

            if (settings.ShowPackets)
            {
                LogDebug("C -> S: " + packet);
            }
            if (settings.ShowPacketData)
            {
                LogDebug(Util.GetPacketDump(packet.GetBytes(), false));
            }

            byte[] packetBytes = packet.GetBytes();
            try
            {
                client.GetStream().Write(packetBytes, 0, packetBytes.Length);
            }
            catch (Exception)
            {
                if (!IsDisconnecting && !IsExiting)
                {
                    Fail(FailureArgs.FailureTypes.FailedToSend, "Failed to send packet to game server");
                }
                return;
            }
        }
Example #2
0
        /// <summary>
        /// Sends a packet to the game server.
        /// </summary>
        /// <param name="type">The type of packet to send.</param>
        /// <param name="data">The packet data (Not the packet header).</param>
        public void SendPacket(GameServerOutPacketType type, byte[] data)
        {
            GameClientPacket packet = new GameClientPacket();
            packet.Id = type;
            packet.Data = data;

            if (settings.ShowPackets)
            {
                LogDebug("C -> S: " + packet);
            }
            if (settings.ShowPacketData)
            {
                LogDebug(Util.GetPacketDump(packet.GetBytes(), false));
            }

            byte[] packetBytes = packet.GetBytes();
            try
            {
                client.GetStream().Write(packetBytes, 0, packetBytes.Length);
            }
            catch (Exception)
            {
                if (!IsDisconnecting && !IsExiting)
                {
                    Fail(FailureArgs.FailureTypes.FailedToSend, "Failed to send packet to game server");
                }
                return;
            }
        }