示例#1
0
        /// <summary>
        /// Sends a HeapItem to the connected client.  The HeapItem must be a valid
        /// Terraria packet.
        /// </summary>
        /// <remarks>
        /// Heap item must point to a valid packet.
        /// </remarks>
        protected void SendHeapItem(HeapItem item)
        {
            if (item.Heap == null)
            {
                return;
            }

            try
            {
                int         length    = BitConverter.ToInt16(item.Heap, item.Offset);
                PacketTypes type      = (PacketTypes)item.Heap[item.Offset + 2];
                TcpClient   tcpClient = (client.Socket as TcpSocket)._connection;

                tcpClient.GetStream().Write(item.Heap, item.Offset, length);

                if (type == PacketTypes.Disconnect)
                {
                    Netplay.Clients[client.Id].PendingTermination = true;
                }
            }
            catch
            {
                Netplay.Clients[client.Id].PendingTermination = true;
            }
            finally
            {
                Free(item.Block, item.HeapType);
            }
        }
示例#2
0
        public void Enqueue(HeapItem item)
        {
            if (item.Block == -1)
            {
                return;
            }

            lock (_syncRoot)
            {
                sendQueue.Enqueue(item);
                Monitor.Pulse(_syncRoot);
            }
        }
示例#3
0
        /// <summary>
        /// Enqueues a heap item into the send queue.  Packets enqued will be sent to the client.
        /// </summary>
        public void Enqueue(HeapItem item)
        {
            if (item.Block == -1 || item.Heap == null)
            {
                return;
            }

            lock (_syncRoot)
            {
                sendQueue.Enqueue(item);
                Monitor.Pulse(_syncRoot);
            }
            //Trace.WriteLine($"Enqueue on {client.Id}");
        }
示例#4
0
        /// <summary>
        /// Sends a HeapItem to the connected client.  The HeapItem must be a valid
        /// Terraria packet.
        /// </summary>
        /// <remarks>
        /// Heap item must point to a valid packet.
        /// </remarks>
        protected void SendHeapItem(HeapItem item)
        {
            if (item.Heap == null)
            {
                return;
            }

            try
            {
                int length = BitConverter.ToInt16(item.Heap, item.Offset);
                PacketTypes type = (PacketTypes)item.Heap[item.Offset + 2];
                TcpClient tcpClient = (client.Socket as TcpSocket)._connection;

                tcpClient.GetStream().Write(item.Heap, item.Offset, length);

                if (type == PacketTypes.Disconnect)
                {
                    Netplay.Clients[client.Id].PendingTermination = true;
                }
            }
            catch
            {
                Netplay.Clients[client.Id].PendingTermination = true;
            }
            finally
            {
                Free(item.Block, item.HeapType);
            }
        }
示例#5
0
        /// <summary>
        /// Enqueues a heap item into the send queue.  Packets enqued will be sent to the client.
        /// </summary>
        public void Enqueue(HeapItem item)
        {
            if (item.Block == -1 || item.Heap == null)
            {
                return;
            }

            lock (_syncRoot)
            {
                sendQueue.Enqueue(item);
                Monitor.Pulse(_syncRoot);
            }
            //Trace.WriteLine($"Enqueue on {client.Id}");
        }
示例#6
0
        public void Enqueue(HeapItem item)
        {
            if (item.Block == -1)
            {
                return;
            }

            lock (_syncRoot)
            {
                sendQueue.Enqueue(item);
                Monitor.Pulse(_syncRoot);
            }
        }