public void SendPacket(Player player, DataPacket pk, bool immediate = false)
        {
            RakNetSession session = this.server.GetSession(player.EndPoint);

            if (session == null)
            {
                return;
            }

            DataPacketSendArgs args = new DataPacketSendArgs(player, pk);

            ServerEvents.OnPacketSend(args);

            if (args.IsCancel)
            {
                return;
            }

            pk.Encode();

            byte[] buffer = pk.ToArray();

            BinaryStream st = new BinaryStream();

            st.WriteVarInt((int)pk.Length);
            st.WriteBytes(buffer);

            BatchPacket bp = new BatchPacket();

            bp.Payload = st.ToArray();
            bp.Encode();

            RakNet.Packets.EncapsulatedPacket enc = new RakNet.Packets.EncapsulatedPacket();

            enc.buffer       = bp.ToArray();
            enc.reliability  = RakNet.Packets.PacketReliability.RELIABLE;
            enc.messageIndex = ++session.MessageIndex;

            //Logger.Log("%server_packet_send", buffer[0].ToString("X"), buffer.Length);

            session.SendPacket(enc, immediate);
        }