Ejemplo n.º 1
0
        private void FlushMessageQueue()
        {
            while (true)
            {
                // When we call BeginReadLine, we also need to flush the queue
                // So there could be a race between the ReadBuffer and BeginReadLine
                // We need to take lock before DeQueue.
                lock (m_lock)
                {
                    var state = m_state;
                    if (state == State.Stopped || state == State.Stopping)
                    {
                        // May have switched to stopping/stopped state after entering this method.
                        // In that case, don't flush message queue and just return
                        return;
                    }

                    if (m_messageQueue.Count == 0)
                    {
                        return;
                    }

                    string s   = m_messageQueue.Dequeue();
                    bool?  ret = m_userCallBack?.Invoke(s);
                    if (ret.HasValue && !ret.Value)
                    {
                        // This allows for the callback to indicate an error state and break the
                        // processing loop.
                        // Error encountered. Stop processing.
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private async Task ReadAsync()
        {
            try
            {
                while (true)
                {
                    string line = await m_reader.ReadLineAsync();

                    m_userCallBack?.Invoke(line);

                    if (line == null)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new BuildXLException("Exception occured when reading from pipe", ex);
            }
        }
Ejemplo n.º 3
0
        public void Event_StreamDataReceived(BoltConnection connection, UdpStreamData streamData)
        {
            INetworkInterfaceConnection interfaceConnection = FindInterfaceConnection(connection);

            if (interfaceConnection == null)
            {
                Log.Error($"[PhotonNetworkInterface] Received stream data from an unknown connection: {connection}.");
                return;
            }

            IStreamChannel streamChannel = FindStreamChannel(streamData.Channel);

            if (streamChannel == null)
            {
                Log.Error($"[PhotonNetworkInterface] Received stream data from an unknown channel '{streamData.Channel}'.");
                return;
            }

            Log.Info(LogChannel, "[PhotonNetworkInterface] Incoming stream data received: (length)" + streamData.Data.Length);

            StreamDataReceived?.Invoke(streamData.Data, streamChannel, interfaceConnection);
        }