public void Send(DocumentChange documentChange)
 {
     OnDocumentChangeNotification?.Invoke(documentChange);
 }
Esempio n. 2
0
        private void NotifySubscribers(string type, BlittableJsonReaderObject value, List <DatabaseConnectionState> states)
        {
            switch (type)
            {
            case nameof(DocumentChange):
                var documentChange = DocumentChange.FromJson(value);
                foreach (var state in states)
                {
                    state.Send(documentChange);
                }
                break;

            case nameof(CounterChange):
                var counterChange = CounterChange.FromJson(value);
                foreach (var state in states)
                {
                    state.Send(counterChange);
                }
                break;

            case nameof(IndexChange):
                var indexChange = IndexChange.FromJson(value);
                foreach (var state in states)
                {
                    state.Send(indexChange);
                }
                break;

            case nameof(OperationStatusChange):
                var operationStatusChange = OperationStatusChange.FromJson(value, _conventions);
                foreach (var state in states)
                {
                    state.Send(operationStatusChange);
                }
                break;

            case nameof(TopologyChange):
                var topologyChange = TopologyChange.FromJson(value);

                var requestExecutor = _requestExecutor;
                if (requestExecutor != null)
                {
                    var node = new ServerNode
                    {
                        Url      = topologyChange.Url,
                        Database = topologyChange.Database
                    };

                    requestExecutor.UpdateTopologyAsync(new RequestExecutor.UpdateTopologyParameters(node)
                    {
                        TimeoutInMs = 0,
                        ForceUpdate = true,
                        DebugTag    = "topology-change-notification"
                    }).ConfigureAwait(false);
                }
                break;

            default:
                throw new NotSupportedException(type);
            }
        }