Пример #1
0
        private void HandleSendQueue()
        {
            QueuedPacket packet = null;

            lock (SyncLock)
            {
                packet = SendQueue.Dequeue();
            }

            if (packet != null && packet.Data != null)
            {
                var se = SocketError.SocketError;

                NetworkSocket?.Send(packet.Data, 0, packet.Data.Length, SocketFlags.None, out se);

                if (se != SocketError.Success)
                {
                    Disconnect(new SocketException());
                    return;
                }
                else
                {
                    packet.HasBeenSent(this);
                }
            }
        }
Пример #2
0
        private void HandleSend(object state)
        {
            if (SendQueue.Count == 0)
            {
                return;
            }

            byte[] payload;
            lock (_lock)
            {
                payload = SendQueue.Dequeue();
            }

            NetworkSocket.Send(payload);
        }