Exemplo n.º 1
0
 private void Send(Task task)
 {
     lock (_connectionLock)
     {
         var corrId = Guid.NewGuid();
         _items.TryAdd(corrId, new WorkerItem(corrId, task));
         _connection.EnqueueSend(task.CreateNetworkPackage(corrId).AsByteArray());
     }
 }
Exemplo n.º 2
0
 public void Send(VerificationEvent evnt)
 {
     lock (_connectionLock)
     {
         var corrId = Guid.NewGuid();
         _events.TryAdd(corrId, new WorkerItem(corrId, evnt));
         _connection.EnqueueSend(_packager(corrId, evnt).AsByteArray());
     }
 }
Exemplo n.º 3
0
 private void Send(WorkItem workItem)
 {
     lock (_connectionLock)
     {
         _inProgress.TryAdd(workItem.Operation.CorrelationId, workItem);
         _connection.EnqueueSend(workItem.Operation.CreateNetworkPackage().AsByteArray());
     }
 }
Exemplo n.º 4
0
        public Task Subscribe(string stream, Action <RecordedEvent> eventAppeared, Action subscriptionDropped)
        {
            var id     = Guid.NewGuid();
            var source = new TaskCompletionSource <object>();

            if (_subscriptions.TryAdd(id, new Subscription(source, id, stream, eventAppeared, subscriptionDropped)))
            {
                var subscribe = new ClientMessages.SubscribeToStream(stream);
                var pkg       = new TcpPackage(TcpCommand.SubscribeToStream, id, subscribe.Serialize());
                _connection.EnqueueSend(pkg.AsByteArray());
            }
            else
            {
                source.SetException(new Exception("Failed to add subscription. Concurrency failure."));
            }

            return(source.Task);
        }