Exemple #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());
     }
 }
Exemple #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());
     }
 }
 private void Send(WorkItem workItem)
 {
     lock (_connectionLock)
     {
         _inProgress.TryAdd(workItem.Operation.CorrelationId, workItem);
         _connection.EnqueueSend(workItem.Operation.CreateNetworkPackage().AsByteArray());
     }
 }
        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);
        }