示例#1
0
        public override bool Subscribe(AdapterReaderQos qos, QueryParameters queryParameters,
                                       AdapterDataCallback <TDataType> clientCallback)
        {
            if (queryParameters == null)
            {
                throw new ArgumentNullException("queryParameters");
            }
            try
            {
                Callback callback = null;
                if (clientCallback != null)
                {
                    callback = new Callback(clientCallback);
                }

                var subcriber = new Subscriber <TDataType>(topic, queryParameters.Partition, qos,
                                                           callback == null ? null : callback.Listener, 10);
                lock (gate)
                {
                    subscribers.Add(new Subscription(subcriber, callback));
                }

                return(true);
            }
            catch (Exception exception)
            {
                Trace.TraceError("Failed to subscribe to topic: {0} with params: {1} and qos: {2}, error: {3}", topic,
                                 queryParameters, qos, exception);
            }

            return(false);
        }
        public DataReaderListener(AdapterDataCallback <T> callback, bool snapshot)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            this.callback = callback;
            this.snapshot = snapshot;
        }
示例#3
0
            public Callback(AdapterDataCallback <TDataType> clientCallback)
            {
                if (isDisposed)
                {
                    return;
                }

                if (clientCallback == null)
                {
                    throw new ArgumentNullException("clientCallback");
                }

                this.clientCallback = clientCallback;
                listener            = new DataReaderListener <TDataType>(this, false);
            }
示例#4
0
 public abstract bool Subscribe(AdapterReaderQos qos, QueryParameters queryParameters,
                                AdapterDataCallback <TDataType> clientCallback);