Exemplo n.º 1
0
        public Guid?RemoteListen <T>(int bufSize = 1, TimeSpan?interval = null, bool autoUnsubscribe = true,
                                     IEventFilter <T> localListener = null, IEventFilter <T> remoteFilter = null, params int[] types)
            where T : IEvent
        {
            IgniteArgumentCheck.Ensure(bufSize > 0, "bufSize", "should be > 0");
            IgniteArgumentCheck.Ensure(interval == null || interval.Value.TotalMilliseconds > 0, "interval", "should be null or >= 0");

            return(DoOutInOp((int)Op.RemoteListen,
                             writer =>
            {
                writer.WriteInt(bufSize);
                writer.WriteLong((long)(interval == null ? 0 : interval.Value.TotalMilliseconds));
                writer.WriteBoolean(autoUnsubscribe);

                writer.WriteBoolean(localListener != null);

                if (localListener != null)
                {
                    var listener = new RemoteListenEventFilter(Ignite, e => localListener.Invoke((T)e));
                    writer.WriteLong(Ignite.HandleRegistry.Allocate(listener));
                }

                writer.WriteBoolean(remoteFilter != null);

                if (remoteFilter != null)
                {
                    writer.Write(remoteFilter);
                }

                WriteEventTypes(types, writer);
            },
                             reader => Marshaller.StartUnmarshal(reader).ReadGuid()));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Invokes local filter using data from specified stream.
        /// </summary>
        /// <typeparam name="T">Event object type.</typeparam>
        /// <param name="stream">The stream.</param>
        /// <param name="listener">The listener.</param>
        /// <returns>Filter invocation result.</returns>
        private bool InvokeLocalFilter <T>(IPortableStream stream, IEventFilter <T> listener) where T : IEvent
        {
            var evt = EventReader.Read <T>(Marshaller.StartUnmarshal(stream));

            // No guid in local mode
            return(listener.Invoke(Guid.Empty, evt));
        }
Exemplo n.º 3
0
            /** <inheritdoc /> */
            public int Invoke(IBinaryStream stream)
            {
                var evt = EventReader.Read <T>(_marshaller.StartUnmarshal(stream));

                return(_listener.Invoke(evt) ? 1 : 0);
            }
Exemplo n.º 4
0
        /// <summary>
        /// Invokes local filter using data from specified stream.
        /// </summary>
        /// <typeparam name="T">Event object type.</typeparam>
        /// <param name="stream">The stream.</param>
        /// <param name="listener">The listener.</param>
        /// <returns>Filter invocation result.</returns>
        private bool InvokeLocalFilter <T>(IBinaryStream stream, IEventFilter <T> listener) where T : IEvent
        {
            var evt = EventReader.Read <T>(Marshaller.StartUnmarshal(stream));

            return(listener.Invoke(evt));
        }