Example #1
0
    public void Send(BasePacket packetToSend)
    {
        try
        {
            if (socket == null)
            {
                Debug.Log("sockt is null/missing");
            }

            socket.BeginSend(packetToSend.GetPacketBytes(), 0, packetToSend.GetPacketBytes().Length, 0,
                             new AsyncCallback(SendCallBack), socket);
        }
        catch
        {
            Debug.Log("should boot back to login menu");
            //boot back to login menu
        }
    }
Example #2
0
    public byte[] GetNextPacketInQueue()
    {
        if (!SocketConnected(socket))
        {
            return(null);
        }


        while (sendPacketQueue.Count > 0)
        {
            BasePacket packet      = sendPacketQueue.Dequeue();
            byte[]     packetBytes = packet.GetPacketBytes();
            byte[]     buffer      = new byte[0xffff];
            Array.Copy(packetBytes, buffer, packetBytes.Length);
            return(buffer);
        }
        throw new Exception("Something happened in getting queued packet");
    }
Example #3
0
        public void FlushQueuedSendPackets()
        {
            if (!socket.Connected)
            {
                return;
            }

            while (SendPacketQueue.Count > 0)
            {
                BasePacket packet      = SendPacketQueue.Take();
                byte[]     packetBytes = packet.GetPacketBytes();
                byte[]     buffer      = new byte[0xffff];
                Array.Copy(packetBytes, buffer, packetBytes.Length);
                try {
                    socket.Send(packetBytes);
                }
                catch (Exception e)
                { Program.Log.Error("Weird case, socket was d/ced: {0}", e); }
            }
        }
Example #4
0
    public void FlushQueuedSendPackets(BasePacketConnectionTypes header = BasePacketConnectionTypes.Zone)
    {
        if (!socket.Connected)
        {
            return;
        }

        while (sendPacketQueue.Count > 0)
        {
            BasePacket packet = BasePacket.CreatePacket(sendPacketQueue, PacketProcessor.isAuthenticated, false);
            packet.header.connectionType = (ushort)header;

            try
            {
                socket.Send(packet.GetPacketBytes());
                sendPacketQueue.Clear();
            }
            catch (Exception e)
            {
                Console.WriteLine("Weird case, socket was d/ced: {0}", e);
            }
        }
    }
        public void FlushQueuedSendPackets()
        {
            if (!socket.Connected)
            {
                return;
            }

            while (SendPacketQueue.Count > 0)
            {
                BasePacket packet = SendPacketQueue.Take();

                byte[] packetBytes = packet.GetPacketBytes();

                try
                {
                    socket.Send(packetBytes);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Weird case, socket was d/ced: {0}", e);
                }
            }
        }