Exemplo n.º 1
0
    /// <summary>
    /// The worker in charge of sending data across the network
    /// </summary>
    private void SendWorker()
    {
        while (m_Running)
        {
            if (m_SendBuffer.Count == 0)
            {
                continue;
            }

            SendChunk chunk = m_SendBuffer.Dequeue();
            byte[]    bytes = chunk.m_Data.ToBytes();

            if (chunk.m_Data.m_TargetId == "server" || chunk.m_Data.m_TargetId == "proxy")
            {
                m_Client.Send(bytes, bytes.Length);
            }
            else
            {
                if (!m_Endpoints.TryGetValue(chunk.m_Data.m_TargetId, out IPEndPoint point))
                {
                    return;
                }
                m_Client.Send(bytes, bytes.Length, point);
            }
            m_SentFrames++;
        }

        Thread.CurrentThread.Abort();
    }
Exemplo n.º 2
0
    /// <summary>
    /// Queues up a frame to be sent across the network
    /// </summary>
    /// <param name="frame">The frame of data that is going to be sent</param>
    /// <param name="target">The target of whom this is going to, if left null then to the connected client</param>
    public void QueueFrame(NetworkFrame frame)
    {
        SendChunk chunk = new SendChunk(frame);

        m_SendBuffer.Enqueue(chunk);
    }