public AutoCloseDuplexSessionChannel(IDuplexSessionChannel innerChannel)
 {
     this.innerChannel            = innerChannel;
     this.pendingMessages         = new InputQueue <Message>();
     this.messageDequeuedCallback = new Action(this.StartBackgroundReceive);
     this.closeState = new CloseState();
 }
Exemplo n.º 2
0
        public void EntryPoint()
        {
            this.ThreadEndedEvent.Reset();

            try
            {
                // loop receiving from the server until:
                //   - the foreground thread wants to shutdown the connection. It has set
                //     the ShutdownFlag event.
                while ((ShutdownFlag.State == false))
                {
                    var message = InputQueue.WaitAndDequeue(this.ShutdownFlag.EventObject);
                    if (message != null)
                    {
                        if (message is CaptureContentMessage)
                        {
                            var captureMessage = message as CaptureContentMessage;
                            DoCapture(captureMessage.ScreenDefn, captureMessage.ScreenContent,
                                      captureMessage.CaptureFolderPath);
                        }
                        if (message is GeneralThreadMessage)
                        {
                            var generalMessage = message as GeneralThreadMessage;
                            var screenContent  = generalMessage.ScreenContent;
                        }
                    }
                }
            }
            finally
            {
                // in case anyone waiting for this thread to end. Signal the ended event.
                ThreadEndedEvent.Set();
            }
        }
        public async Task ProcessInputQueue()
        {
            if (!InputQueue.IsEmpty)
            {
                string fileName;
                while (InputQueue.TryDequeue(out fileName))
                {
                    await Task.Run(() =>
                    {
                        string outputFileName = Path.Combine(Settings.InProcessDir, Path.GetFileName(fileName));
                        if (File.Exists(outputFileName))
                        {
                            File.Delete(outputFileName);
                        }
                        File.Move(fileName, outputFileName);
                        InprocessQueue.Enqueue(outputFileName);
                        Console.WriteLine("File - " + outputFileName + " - moved to inprocess location.");
                    });
                }
            }

            //await Console.Out.WriteLineAsync("Starting inprocess queue processing...");

            // Process uploads
            await ProcessInprocessQueue();

            //await Console.Out.WriteLineAsync("Completed processing inprocess queue...");
        }
 public MakeConnectionDispatcher(Uri uri, object lockObj)
 {
     this.contexts = new InputQueue<MakeConnectionRequestContext>();
     this.contextDictionary = new Dictionary<UniqueId, MakeConnectionRequestContext>();
     this.Uri = uri;
     this.lockObj = lockObj;
 }
Exemplo n.º 5
0
 public async Task <int> ExecuteAsync(
     string workingDirectory,
     string fileName,
     string arguments,
     IDictionary <string, string> environment,
     bool requireExitCodeZero,
     Encoding outputEncoding,
     bool killProcessOnCancel,
     InputQueue <string> redirectStandardIn,
     bool inheritConsoleHandler,
     bool keepStandardInOpen,
     bool highPriorityProcess,
     CancellationToken cancellationToken)
 {
     _invoker.ErrorDataReceived  += this.ErrorDataReceived;
     _invoker.OutputDataReceived += this.OutputDataReceived;
     return(await _invoker.ExecuteAsync(
                workingDirectory,
                fileName,
                arguments,
                environment,
                requireExitCodeZero,
                outputEncoding,
                killProcessOnCancel,
                redirectStandardIn,
                inheritConsoleHandler,
                keepStandardInOpen,
                highPriorityProcess,
                cancellationToken));
 }
Exemplo n.º 6
0
 private static void Initialize()
 {
     ParentServerConfig = new ParentConfig(2);
     ServerConfig       = new NetConfig();
     ServerConfig.SetMaxBackLogConnections(MAXIMUM_BACKLOG);
     ServerConfig.SetMaxConnections(MAXIMUM_CONNECTIONS);
     ServerConfig.SetMaxMessageSize(MESSAGE_SIZE);
     ServerConfig.SetBufferSize(BUFFER_SIZE);
     ServerConfig.SetHeaderSize(HEADER_SIZE);
     ServerConfig.SetEnableKeepAlive(false);
     ServerConfig.SetPort(1660);
     ParentServer = new Parent(ParentServerConfig, ServerConfig);
     ParentServer.OnParentCreatedEvent     += ParentServer_OnParentCreatedEvent;
     ParentServer.OnParentClosedEvent      += ParentServer_OnParentClosedEvent;
     ParentServer.OnExceptionEvent         += ParentServer_OnExceptionEvent;
     ParentServer.OnChildCreateEvent       += ParentServer_OnChildCreateEvent;
     ParentServer.OnChildConnectEvent      += ParentServer_OnChildConnectEvent;
     ParentServer.OnChildAuthenticateEvent += ParentServer_OnChildAuthenticateEvent;
     ParentServer.OnChildSendEvent         += ParentServer_OnChildSendEvent;
     ParentServer.OnChildReceiveEvent      += ParentServer_OnChildReceiveEvent;
     ParentServer.OnChildDisconnectEvent   += ParentServer_OnChildDisconnectEvent;
     ParentServer.OnChildDestroyEvent      += ParentServer_OnChildDestroyEvent;
     Input  = new InputQueue(ParentServer);
     Output = new OutputQueue();
     Output.OnFrameEvent += Output_OnFrameEvent;
     ParentServer.StartParent();
     PacketHandler = new PacketHandler(Input, Output, MainLogger);
     ConnectPipeline();
     Pipeline.SendMessage(new IViewNet.Common.Models.Packet(1111, "SetDetectionType", new byte[1024 * 19]));
     Console.ReadKey();
 }
Exemplo n.º 7
0
 public App(string appKey, string path, int siteId, string appPoolId)
 {
     this.path = path;
     this.appPoolId = appPoolId;
     this.appKey = appKey;
     this.messageQueue = new InputQueue<RequestContext>();
 }
Exemplo n.º 8
0
 public Task <int> ExecuteAsync(
     string workingDirectory,
     string fileName,
     string arguments,
     IDictionary <string, string> environment,
     bool requireExitCodeZero,
     Encoding outputEncoding,
     bool killProcessOnCancel,
     InputQueue <string> redirectStandardIn,
     bool inheritConsoleHandler,
     bool keepStandardInOpen,
     CancellationToken cancellationToken)
 {
     return(ExecuteAsync(
                workingDirectory: workingDirectory,
                fileName: fileName,
                arguments: arguments,
                environment: environment,
                requireExitCodeZero: requireExitCodeZero,
                outputEncoding: outputEncoding,
                killProcessOnCancel: killProcessOnCancel,
                redirectStandardIn: redirectStandardIn,
                inheritConsoleHandler: inheritConsoleHandler,
                keepStandardInOpen: keepStandardInOpen,
                highPriorityProcess: false,
                cancellationToken: cancellationToken
                ));
 }
        public RandomDelayQueuedSendsAsyncResult(
            TimeSpan maxRandomDelay,
            InputQueue <TItem> itemQueue,
            AsyncCallback callback,
            object state)
            : base(callback, state)
        {
            Fx.Assert(maxRandomDelay >= TimeSpan.Zero, "The maxRandomDelay parameter must be non negative.");
            Fx.Assert(itemQueue != null, "The itemQueue parameter must be non null.");

            this.itemQueue = itemQueue;

            this.doDelay = maxRandomDelay > TimeSpan.Zero;
            if (this.doDelay)
            {
                this.random = new Random();
                this.maxRandomDelayInMillis = maxRandomDelay.TotalMilliseconds;

                if (this.itemQueue.PendingCount > 0)
                {
                    this.preCalculatedDelays = new int[this.itemQueue.PendingCount];
                    this.PreCalculateSendDelays();
                }
            }
        }
Exemplo n.º 10
0
        private void StartWriteStream(InputQueue <string> redirectStandardIn, StreamWriter standardIn)
        {
            Task.Run(async() =>
            {
                // Write the contents as UTF8 to handle all characters.
                var utf8Writer = new StreamWriter(standardIn.BaseStream, new UTF8Encoding(false));

                while (!_processExitedCompletionSource.Task.IsCompleted)
                {
                    Task <string> dequeueTask = redirectStandardIn.DequeueAsync();
                    var completedTask         = await Task.WhenAny(dequeueTask, _processExitedCompletionSource.Task);
                    if (completedTask == dequeueTask)
                    {
                        string input = await dequeueTask;
                        if (!string.IsNullOrEmpty(input))
                        {
                            utf8Writer.WriteLine(input);
                            utf8Writer.Flush();
                        }
                    }
                }

                Trace.Info("STDIN stream write finished.");
            });
        }
Exemplo n.º 11
0
 public AutoCloseDuplexSessionChannel(IDuplexSessionChannel innerChannel)
 {
     this.innerChannel       = innerChannel;
     pendingMessages         = new InputQueue <Message>();
     messageDequeuedCallback = new Action(StartBackgroundReceive); // kick off a new receive when a message is picked up
     closeState = new CloseState();
 }
Exemplo n.º 12
0
        public override void ReadBytes()
        {
            using (var fsInput = new FileStream(FileSource, FileMode.Open, FileAccess.Read))
            {
                var length      = _fileSize;
                var blockLength = BlockProcessingLength;

                while (blockLength > 0 && !ForceStopped)
                {
                    var bytesArray = new byte[blockLength];
                    var readCount  = fsInput.Read(bytesArray, 0, bytesArray.Length);

                    InputQueue.Push(new BytesBlock(ReadedBlockCount, bytesArray));

                    ++ReadedBlockCount;
                    length -= readCount;

                    blockLength = length < blockLength ? length : blockLength;
                }

                if (ForceStopped)
                {
                    return;
                }
                InputQueue.Complete();
            }
        }
Exemplo n.º 13
0
        protected override void ReadInputFile()
        {
            try
            {
                using (var sourceStream = new FileStream(InputFilePath, FileMode.Open, FileAccess.Read))
                    using (var binaryReader = new BinaryReader(sourceStream))
                    {
                        var fileInfo = new FileInfo(InputFilePath);
                        var fileSize = fileInfo.Length;

                        const int intSize = 4;
                        var       chunkId = 0;

                        while (fileSize > 0 && !hasError)
                        {
                            var chunkSize = binaryReader.ReadInt32();
                            var bytes     = binaryReader.ReadBytes(chunkSize);
                            InputQueue.Enqueue(new Chunk(chunkId++, bytes));
                            fileSize -= (chunkSize + intSize);
                            if (fileSize == 0)
                            {
                                InputQueue.ReadComplete();
                            }
                        }
                    }
            }
            catch (Exception e)
            {
                hasError = true;
            }
        }
Exemplo n.º 14
0
        public async Task RunPluginTaskAsync(IExecutionContext context, string plugin, Dictionary <string, string> inputs, Dictionary <string, string> environment, Variables runtimeVariables, EventHandler <ProcessDataReceivedEventArgs> outputHandler)
        {
            ArgUtil.NotNullOrEmpty(plugin, nameof(plugin));

            // Only allow plugins we defined
            if (!_taskPlugins.Contains(plugin))
            {
                throw new NotSupportedException(plugin);
            }

            // Resolve the working directory.
            string workingDirectory = HostContext.GetDirectory(WellKnownDirectory.Work);

            ArgUtil.Directory(workingDirectory, nameof(workingDirectory));

            // Agent.PluginHost
            string file = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Bin), $"Agent.PluginHost{Util.IOUtil.ExeExtension}");

            ArgUtil.File(file, $"Agent.PluginHost{Util.IOUtil.ExeExtension}");

            // Agent.PluginHost's arguments
            string arguments = $"task \"{plugin}\"";

            // construct plugin context
            var target = context.StepTarget();
            AgentTaskPluginExecutionContext pluginContext = new AgentTaskPluginExecutionContext
            {
                Inputs       = inputs,
                Repositories = context.Repositories,
                Endpoints    = context.Endpoints,
                Container    = target is ContainerInfo ? target as ContainerInfo : null, //TODO: Figure out if this needs to have all the containers or just the one for the current step
                JobSettings  = context.JobSettings,
            };

            // variables
            runtimeVariables.CopyInto(pluginContext.Variables);
            context.TaskVariables.CopyInto(pluginContext.TaskVariables);

            using (var processInvoker = HostContext.CreateService <IProcessInvoker>())
            {
                var redirectStandardIn = new InputQueue <string>();
                redirectStandardIn.Enqueue(JsonUtility.ToString(pluginContext));

                processInvoker.OutputDataReceived += outputHandler;
                processInvoker.ErrorDataReceived  += outputHandler;

                // Execute the process. Exit code 0 should always be returned.
                // A non-zero exit code indicates infrastructural failure.
                // Task failure should be communicated over STDOUT using ## commands.
                await processInvoker.ExecuteAsync(workingDirectory : workingDirectory,
                                                  fileName : file,
                                                  arguments : arguments,
                                                  environment : environment,
                                                  requireExitCodeZero : true,
                                                  outputEncoding : Encoding.UTF8,
                                                  killProcessOnCancel : false,
                                                  redirectStandardIn : redirectStandardIn,
                                                  cancellationToken : context.CancellationToken);
            }
        }
Exemplo n.º 15
0
 public void AddAsciiInput(string ascii)
 {
     foreach (char item in ascii)
     {
         InputQueue.Enqueue(item);
     }
 }
Exemplo n.º 16
0
        public void Run()
        {
            while (!Abort)
            {
                string path = InputQueue.DequeueLast();

                IsActive = true;

                if (Directory.Exists(path))
                {
                    Console.WriteLine("{0}: Starting refresh and cleanup", GetType().Name);

                    DateTime start = DateTime.Now;
                    ProcessDirectoryForAdd(path, FilenamesIgnoreCase());
                    Console.WriteLine("{0}: Refresh took {1} ms", GetType().Name, (DateTime.Now - start).TotalMilliseconds);

                    start = DateTime.Now;
                    ProcessFilesForRemove(FilenamesIgnoreCase());
                    Console.WriteLine("{0}: Cleanup took {1} ms", GetType().Name, (DateTime.Now - start).TotalMilliseconds);

                    start = DateTime.Now;
                    RemoveCaseInsensitiveDuplicateTracks();
                    Console.WriteLine("{0}: Remove duplicate names took {1} ms", GetType().Name, (DateTime.Now - start).TotalMilliseconds);
                }
                databaseChanger.Flush();

                if (InputQueue.Count == 0)
                {
                    WorkerThreadPool.Instance.InvokingThread.BeginInvokeLowPrio(FinishCallback);
                }

                IsActive = false;
            }
        }
Exemplo n.º 17
0
        protected void RaiseChannelAdded(ActorChannel channel)
        {
            Channels.Add(channel);
            var channelAddedEvent = new ChannelAddedEvent(channel);

            InputQueue.Add(channelAddedEvent);
        }
Exemplo n.º 18
0
            public void Run()
            {
                while (_iPointer >= 0 && _iPointer < Memory.Length)
                {
                    var instruction = Memory[_iPointer];
                    var opCode      = instruction % 100;

                    switch (opCode)
                    {
                    case 1: Add(); break;

                    case 2: Multiply(); break;

                    case 3: if (!InputQueue.Any())
                        {
                            return;
                        }
                        ReadInput(); break;

                    case 4: WriteOutput(); break;

                    case 5: JumpIfTrue(); break;

                    case 6: JumpIfFalse(); break;

                    case 7: LessThan(); break;

                    case 8: Equals(); break;

                    case 99: Halted = true; return;

                    default: throw new Exception($"Unexpected opcode: {opCode}");
                    }
                }
            }
Exemplo n.º 19
0
        protected override void Execute(CodeActivityContext activityContext)
        {
            Queue <T> queue = InputQueue.Get(activityContext);
            T         item  = Item.Get(activityContext);

            queue.Enqueue(item);
        }
Exemplo n.º 20
0
 protected override void ReadInFile()
 {
     try
     {
         var fileSize = InputFileStream.Length;
         using (var binaryReader = new BinaryReader(InputFileStream))
         {
             var chunkId = 0;
             while (fileSize > 0 && HasError == null)
             {
                 var currentChunkSize = fileSize > Const.ChunkSize ? Const.ChunkSize : fileSize;
                 var bytes            = binaryReader.ReadBytes((int)currentChunkSize);
                 InputQueue.Enqueue(new Chunk(chunkId++, bytes));
                 fileSize -= currentChunkSize;
                 if (fileSize == 0)
                 {
                     InputQueue.ReadComplete();
                 }
             }
         }
     }
     catch (Exception e)
     {
         SingleLogger.log.Error($"(Your exception is :{e.Message} , send a log file for us from the  folder /bin/Debug/myapp.log");
         SingleLogger.log.Debug($"(Your exception is :{e.Message} , send a log file for us from the  folder /bin/Debug/myapp.log");
         HasError = e;
     }
 }
Exemplo n.º 21
0
 public App(string appKey, string path, int siteId, string appPoolId)
 {
     this.path         = path;
     this.appPoolId    = appPoolId;
     this.appKey       = appKey;
     this.messageQueue = new InputQueue <RequestContext>();
 }
Exemplo n.º 22
0
        /// <summary>
        /// Processes input queue by dequeueing each
        /// item, moving them to the in process location and
        /// then enqueuing them to the in process queue.
        /// </summary>
        /// <returns>Task object for continuation</returns>
        public async Task processInputQueue()
        {
            if (!InputQueue.IsEmpty)
            {
                ClientDataMessage dataMessage;

                // For each item in the input queue, dequeue and move
                // item to the in process queue
                while (InputQueue.TryDequeue(out dataMessage))
                {
                    var targetDataMessage = new ClientDataMessage()
                    {
                        Name          = dataMessage.Name,
                        FullPath      = Path.Combine(Settings.InProcessDir, dataMessage.Name),
                        MessageStatus = MessageStatus.InProcess
                    };

                    // Move to inprocess location
                    await this.moveDataToTargetAsync(dataMessage, targetDataMessage);

                    // Enqueue to the inprocess queue
                    InprocessQueue.Enqueue(targetDataMessage);

                    // Update stats
                    base.formInstance.logText("File:  " + targetDataMessage.Name + " -  moved to inprocess location.");

                    Interlocked.Increment(ref inprocessJobCount);

                    base.formInstance.updateStats(StatType.Inprocess, inprocessJobCount);
                }
            }

            // Process uploads
            await processInprocessQueue();
        }
Exemplo n.º 23
0
 public PlayerFacade(Animator at, Rigidbody2D rig, Transform trs)
 {
     this.trs    = trs;
     this.rig    = rig;
     _state      = new PlayerIdleState(this);
     _inputQueue = new InputQueue();
     anim        = at;
 }
 public ServiceBusMessageBusCache(int cacheId, TimeSpan ttl)
 {
     this.cacheId = cacheId;
     this.ttl = ttl;
     this.messageIndex = new SortedList<ulong, CachedMessage>();
     this.pendingAdds = new InputQueue<CachedMessage>();
     this.pendingNotifications = new InputQueue<NotificationRegistration>();
 }
Exemplo n.º 25
0
 public DemuxSocketListener(System.Uri uri, string type, DemuxSocketManager demuxManager)
 {
     this.uri             = uri;
     this.type            = type;
     this.demuxManager    = demuxManager;
     this.mutex           = new object();
     this.connectionQueue = new InputQueue <IConnection>();
 }
Exemplo n.º 26
0
        long[] Program3(long[] intCode, long pos)
        {
            var input = InputQueue.Dequeue();

            intCode[pos] = input;
            //InputQueue.Enqueue(2);
            return(intCode);
        }
        int[] Program3(int[] intCode, int pos, Parameter p)
        {
            var input      = InputQueue.Dequeue();
            var inputValue = intCode[pos];

            intCode[inputValue] = input;
            return(intCode);
        }
Exemplo n.º 28
0
        public void EntryPoint()
        {
            this.ThreadEndedEvent.Reset();
            try
            {
                // loop receiving from the server until:
                //   - the foreground thread wants to shutdown the connection. It has set
                //     the ShutdownFlag event.
                while ((ShutdownFlag.State == false))
                {
                    var message = InputQueue.WaitAndDequeue(this.ShutdownFlag.EventObject);
                    if (message != null)
                    {
                        // startup message sent by MainWindow after the threads have been
                        // started. Once startup is completed ( telnet negotiation ) the
                        // startup completed event is signaled back on the MainWindow.
                        if (message is TelnetStartupMessage)
                        {
                            var startupMessage = message as TelnetStartupMessage;
                            if (startupMessage.TypeTelnetDevice == TypeTelnetDevice.Terminal)
                            {
                                TelnetDisplayStartup(
                                    startupMessage.ServerConnectPack,
                                    startupMessage.NegotiateSettings,
                                    startupMessage.TelnetQueue,
                                    FromThread, ToThread,
                                    startupMessage.ClientWindow,
                                    startupMessage.TelnetStartupComplete);
                            }

                            else if (startupMessage.TypeTelnetDevice == TypeTelnetDevice.Printer)
                            {
                                TelnetPrinterStartup(
                                    startupMessage.ServerConnectPack,
                                    startupMessage.NegotiateSettings,
                                    startupMessage.TelnetQueue,
                                    FromThread, ToThread,
                                    startupMessage.ClientWindow,
                                    startupMessage.TelnetStartupComplete);
                            }
                        }

                        else if (message is GeneralThreadMessage)
                        {
                            var generalMessage = message as GeneralThreadMessage;
                            switch (generalMessage.MessageCode)
                            {
                            }
                        }
                    }
                }
            }
            finally
            {
                // in case anyone waiting for this thread to end. Signal the ended event.
                ThreadEndedEvent.Set();
            }
        }
Exemplo n.º 29
0
 public IntcodeComputer(int[] memory, IEnumerable <int> inputs)
 {
     Memory = memory;
     foreach (var input in inputs)
     {
         InputQueue.Enqueue(input);
     }
     OutputBuffer = new List <int>();
 }
Exemplo n.º 30
0
        public void Dispose_causes_subsequent_enqueue_and_dequeue_to_throw_ObjectDisposed()
        {
            InputQueue <string> queue = new InputQueue <string>();

            queue.Dispose();

            Assert.Throws <ObjectDisposedException>(() => queue.Enqueue("a"));
            Assert.Throws <ObjectDisposedException>(() => queue.DequeueAsync());
        }
 public bool TryBackgroundClose()
 {
     if (!this.userClose)
     {
         this.backgroundCloseData = new InputQueue <object>();
         return(true);
     }
     return(false);
 }
Exemplo n.º 32
0
        // Private functions
        private void SortInputs()
        {
            ConsoleHelper.WriteLine(LogType.DEBUG, "sorting input order");
            IEnumerable <Input> inputSetPriority = InputQueue.Where(input => input.InputType == m_priority);
            IEnumerable <Input> inputSet         = InputQueue.Where(input => input.InputType != m_priority);

            InputQueue = inputSetPriority.ToList();
            InputQueue.AddRange(inputSet);
        }
 public HttpCookieReplySessionChannel(HttpCookieReplySessionChannelListener parent, EndpointAddress localAddress)
     : base(parent)
 {
     this.parent = parent;
     this.localAddress = localAddress;
     this.sessionTimeout = parent.SessionTimeout;
     this.session = new HttpCookieReplySession();
     this.requestQueue = new InputQueue<RequestContext>();
 }
Exemplo n.º 34
0
        public ConsoleKeyInfo ReadKey()
        {
            while (KeyAvailable == false)
            {
                Thread.Sleep(10);
            }

            return(InputQueue.Dequeue());
        }
Exemplo n.º 35
0
 public static void ConnectServerChannel(InputQueue<Message> inputQueue,
     InputQueue<Message> outputQueue,
     EndpointAddress remoteAddress, Uri via,
     TimeSpan timeout)
 {
     LocalChannelListener channelListener;
     IDuplexSessionChannel serverChannel = CreateServerChannel
         (inputQueue, outputQueue, remoteAddress, via, out channelListener);
     channelListener.EnqueueNewChannel(serverChannel, timeout);
 }
 internal SharedConnectionListener(BaseUriWithWildcard baseAddress, int queueId, Guid token, Func<Uri, int> onDuplicatedViaCallback)
 {
     this.baseAddress = baseAddress;
     this.queueId = queueId;
     this.token = token;
     this.onDuplicatedViaCallback = onDuplicatedViaCallback;
     this.connectionQueue = TraceUtility.CreateInputQueue<DuplicateConnectionAsyncResult>();
     this.state = CommunicationState.Created;
     this.reconnectEvent = new ManualResetEvent(true);
     this.StartListen(false);
 }
Exemplo n.º 37
0
 public static IAsyncResult BeginConnectServerChannel(InputQueue<Message> inputQueue,
     InputQueue<Message> outputQueue,
     EndpointAddress remoteAddress, Uri via,
     TimeSpan timeout,
     AsyncCallback callback, object state)
 {
     LocalChannelListener channelListener;
     IDuplexSessionChannel serverChannel = CreateServerChannel
         (inputQueue, outputQueue, remoteAddress, via, out channelListener);
     return channelListener.BeginEnqueueNewChannel(serverChannel, timeout, callback, state);
 }
Exemplo n.º 38
0
        public void Enqueue_then_dequeue_completes_sync()
        {
            InputQueue<string> queue = new InputQueue<string>();

            queue.Enqueue("a");

            Task<string> task = queue.DequeueAsync();

            Assert.Equal(TaskStatus.RanToCompletion, task.Status);
            Assert.Equal("a", task.Result);
        }
Exemplo n.º 39
0
        public void Dequeue_completes_after_enqueue()
        {
            InputQueue<string> queue = new InputQueue<string>();
            
            Task<string> task = queue.DequeueAsync();

            Assert.False(task.IsCompleted);

            queue.Enqueue("a");

            Assert.Equal(TaskStatus.RanToCompletion, task.Status);
            Assert.Equal("a", task.Result);
        }
Exemplo n.º 40
0
        public void Multiple_enqueues_then_dequeues_complete_sync_in_order()
        {
            InputQueue<string> queue = new InputQueue<string>();

            queue.Enqueue("a");
            queue.Enqueue("b");

            Task<string> task = queue.DequeueAsync();

            Assert.Equal(TaskStatus.RanToCompletion, task.Status);
            Assert.Equal("a", task.Result);

            task = queue.DequeueAsync();

            Assert.Equal(TaskStatus.RanToCompletion, task.Status);
            Assert.Equal("b", task.Result);
        }
Exemplo n.º 41
0
        public void Dequeue_while_dequeue_still_pending_throws_InvalidOperation()
        {
            InputQueue<string> queue = new InputQueue<string>();

            Task<string> task = queue.DequeueAsync();

            Assert.False(task.IsCompleted);

            Assert.Throws<InvalidOperationException>(() => queue.DequeueAsync());
        }
Exemplo n.º 42
0
 internal ServerLocalDuplexSessionChannel(LocalChannelListener listener, 
     InputQueue<Message>receiveQueue, InputQueue<Message>sendQueue,
     EndpointAddress address, Uri via)
     : base(listener, receiveQueue, sendQueue, address, via)
 {
 }
Exemplo n.º 43
0
 public Subscriber(Container container, string node)
     : base(container, node)
 {
     this.messages = new InputQueue<AmqpMessage>();
 }
Exemplo n.º 44
0
        public void Dequeue_then_enqueue_repeated_twice_completes_pending()
        {
            InputQueue<string> queue = new InputQueue<string>();

            Task<string> task = queue.DequeueAsync();

            Assert.False(task.IsCompleted);

            queue.Enqueue("a");

            Assert.Equal(TaskStatus.RanToCompletion, task.Status);
            Assert.Equal("a", task.Result);

            task = queue.DequeueAsync();

            Assert.False(task.IsCompleted);

            queue.Enqueue("b");

            Assert.Equal(TaskStatus.RanToCompletion, task.Status);
            Assert.Equal("b", task.Result);
        }
Exemplo n.º 45
0
        static IDuplexSessionChannel CreateServerChannel(InputQueue<Message> inputQueue,
            InputQueue<Message> outputQueue,
            EndpointAddress remoteAddress, Uri via,
            out LocalChannelListener channelListener)
        {
            lock (routingTable)
            {
                if (!routingTable.TryGetValue(via, out channelListener))
                {
                    throw new EndpointNotFoundException(String.Format
                        (ExceptionMessages.ChannelListenerNotFound, via.ToString()));
                }
            }

            return new ServerLocalDuplexSessionChannel(channelListener,
                inputQueue, outputQueue, remoteAddress, via);
        }
Exemplo n.º 46
0
        public void Dispose_causes_subsequent_enqueue_and_dequeue_to_throw_ObjectDisposed()
        {
            InputQueue<string> queue = new InputQueue<string>();
            queue.Dispose();

            Assert.Throws<ObjectDisposedException>(() => queue.Enqueue("a"));
            Assert.Throws<ObjectDisposedException>(() => queue.DequeueAsync());
        }
Exemplo n.º 47
0
 public StreamServerHost(params Uri[] baseAddresses)
     : base(typeof(StreamServer), baseAddresses)
 {
     availableStreams = new InputQueue<StreamConnection>();
 }
 public BufferedReceiveBinder(IChannelBinder channelBinder)
 {
     _channelBinder = channelBinder;
     _inputQueue = new InputQueue<RequestContextWrapper>();
 }
Exemplo n.º 49
0
 public AmqpStream(bool encoding)
 {
     this.encoding = encoding;
     this.messages = new InputQueue<ByteBuffer>();
 }
Exemplo n.º 50
0
 public QueueBufferedStream(TimeSpan naglingDelay)
 {
     this.naglingDelay = naglingDelay;
     this.done = new ManualResetEvent(false);
     this.dataChunks = new InputQueue<byte[]>();
 }
Exemplo n.º 51
0
        public void Dispose_completes_pending_receive_with_ObjectDisposed()
        {
            InputQueue<string> queue = new InputQueue<string>();

            Task<string> task = queue.DequeueAsync();

            Assert.False(task.IsCompleted);

            queue.Dispose();

            Assert.True(task.IsFaulted);
            Assert.NotNull(task.Exception);
            AggregateException ae = task.Exception;
            Assert.Equal(1, ae.InnerExceptions.Count);
            Assert.IsType<ObjectDisposedException>(ae.InnerExceptions[0]);
        }