Exemplo n.º 1
0
        public MemstateClient(MemstateSettings config)
        {
            _config             = config;
            _serializer         = config.CreateSerializer();
            _pendingRequests    = new Dictionary <Guid, TaskCompletionSource <Message> >();
            _logger             = _config.LoggerFactory.CreateLogger <MemstateClient <TModel> >();
            _cancellationSource = new CancellationTokenSource();

            _events = new ClientEvents();

            _events.SubscriptionAdded += async(type, filters) =>
            {
                var request = new SubscribeRequest(type, filters.ToArray());

                await SendAndReceive(request);
            };

            _events.SubscriptionRemoved += async type =>
            {
                var request = new UnsubscribeRequest(type);

                await SendAndReceive(request);
            };

            _events.GlobalFilterAdded += async filter =>
            {
                var request = new FilterRequest(filter);

                await SendAndReceive(request);
            };
        }
Exemplo n.º 2
0
        public LocalClient(Engine <TModel> engine)
        {
            _engine = engine;

            _events = new ClientEvents();

            engine.CommandExecuted += (record, local, events) => _events.Handle(events);
        }
Exemplo n.º 3
0
 public LocalClient(Engine <TModel> engine)
 {
     _engine = engine;
     _events = new ClientEvents <TModel>(engine);
 }