Example #1
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="ev">TBD</param>
 public void Notify(IHandleEvent ev)
 {
     if (!_gremlinAdapter.ShouldDropInbound(WrappedHandle.RemoteAddress, ev, "handler.notify"))
     {
         _upstreamListener.Notify(ev);
     }
 }
Example #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parent">A local event handler to send messages to</param>
 /// <param name="network">The network connection to use for handling events</param>
 public NetLogic(IHandleEvent parent, NetPlayer network)
     : base(parent, null, null)
 {
     _network = network;
     network.parent = this;
     _map = new Map();
 }
Example #3
0
 public Dispatching_events()
 {
     _resolver = Substitute.For <IResolver>();
     _executor = Substitute.For <IExecuteEvents>();
     _handler  = Substitute.For <IHandleEvent <TestEvent> >();
     _logger   = Substitute.For <ILogger>();
 }
Example #4
0
        public AkkaProtocolSpec()
        {
            testEnvelope = codec.ConstructMessage(localAkkaAddress, testActor, testMsg);
            testMsgPdu   = codec.ConstructPayload(testEnvelope);

            testHeartbeat = new InboundPayload(codec.ConstructHeartbeat());
            testPayload   = new InboundPayload(testMsgPdu);
        }
Example #5
0
        public async Task StartAsync(IHandleEvent handler, CancellationToken cancellationToken)
        {
            var handlerInstance = (IHandleEvent <TEvent>)handler;

            _backgroundEventHandler = new BackgroundEventHandler <TEvent>(handlerInstance, _client);

            await _backgroundEventHandler.StartAsync(cancellationToken);
        }
Example #6
0
        public AkkaProtocolSpec()
        {
            testEnvelope = codec.ConstructMessage(localAkkaAddress, testActor, testMsg);
            testMsgPdu = codec.ConstructPayload(testEnvelope);

            testHeartbeat = new InboundPayload(codec.ConstructHeartbeat());
            testPayload = new InboundPayload(testMsgPdu);
        }
Example #7
0
        public static void Notify(IConnection channel, IHandleEvent msg)
        {
            IHandleEventListener listener;

            if (_channelActors.TryGetValue(channel, out listener))
            {
                listener.Notify(msg);
            }
        }
Example #8
0
        public AkkaProtocolSpec()
            : base(@"akka.test.default-timeout = 1.5 s")
        {
            testEnvelope = codec.ConstructMessage(localAkkaAddress, TestActor, testMsg);
            testMsgPdu   = codec.ConstructPayload(testEnvelope);

            testHeartbeat = new InboundPayload(codec.ConstructHeartbeat());
            testPayload   = new InboundPayload(testMsgPdu);
        }
Example #9
0
        public static void Notify(IConnection channel, IHandleEvent msg)
        {
            IHandleEventListener listener;

            if (_channelActors.TryGetValue(channel, out listener))
            {
                listener.Notify(msg);
            }
        }
Example #10
0
        public override void Setup()
        {
            base.Setup();
            testEnvelope = codec.ConstructMessage(localAkkaAddress, testActor, testMsg);
            testMsgPdu   = codec.ConstructPayload(testEnvelope);

            testHeartbeat = new InboundPayload(codec.ConstructHeartbeat());
            testPayload   = new InboundPayload(testMsgPdu);
        }
Example #11
0
        public AkkaProtocolSpec()
            : base(@"akka.test.default-timeout = 1.5 s")
        {
            testEnvelope = codec.ConstructMessage(localAkkaAddress, TestActor, testMsg);
            testMsgPdu = codec.ConstructPayload(testEnvelope);

            testHeartbeat = new InboundPayload(codec.ConstructHeartbeat());
            testPayload = new InboundPayload(testMsgPdu);
        }
Example #12
0
 public Logic(IHandleEvent parent, Map map = null, Random random = null)
 {
     _parent = parent;
     if (map != null)
     {
         _map = map;
     }
     if (random == null) _random = new Random();
     else _random = random;
 }
Example #13
0
        public override void Setup()
        {
            base.Setup();
            testEnvelope = codec.ConstructMessage(localAkkaAddress, testActor, testMsg);
            testMsgPdu = codec.ConstructPayload(testEnvelope);

            testHeartbeat = new InboundPayload(codec.ConstructHeartbeat());
            testPayload = new InboundPayload(testMsgPdu);


        }
Example #14
0
        public void Unsubscribe <T>(IHandleEvent <T> handler)
        {
            List <WeakReference> handlers;

            lock (_allHandlers)
            {
                if (_allHandlers.TryGetValue(typeof(T), out handlers) == true)
                {
                    handlers.RemoveAll(wr => ReferenceEquals(wr.Target, handler));
                }
            }
        }
Example #15
0
 public DemoPublisher(IHandleEvent <FundsDepositedEvent> handleDeposit, IHandleEvent <FundsWithdrawalEvent> handleWithdrawal)
 {
     _switch = new Dictionary <Type, Action <IEvent> >
     {
         {
             typeof(FundsDepositedEvent), x => { handleDeposit.Handle((FundsDepositedEvent)x); }
         },
         {
             typeof(FundsWithdrawalEvent), x => { handleWithdrawal.Handle((FundsWithdrawalEvent)x); }
         }
     };
 }
Example #16
0
        public void Subscribe <T>(IHandleEvent <T> handler)
        {
            List <WeakReference> handlers;

            lock (_allHandlers)
            {
                if (_allHandlers.TryGetValue(typeof(T), out handlers) == false)
                {
                    handlers = new List <WeakReference>();
                    _allHandlers.Add(typeof(T), handlers);
                }

                handlers.Add(new WeakReference(handler));
            }
        }
Example #17
0
 private void Handle <TEvent>(TEvent evnt, IHandleEvent <TEvent> handler) where TEvent : IEvent
 {
     try
     {
         handler.Handle(evnt);
     }
     catch
     {
     }
     finally
     {
         var disposable = handler as IDisposable;
         if (disposable != null)
         {
             disposable.Dispose();
         }
     }
 }
Example #18
0
        /// <summary>
        /// The constructor for the logic behind the game
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="map">The map object which will contain the rooms</param>
        /// <param name="_random">A random</param>
        public PureLogic(IHandleEvent parent, Map map = null, Random _random = null)
            : base(parent, map, _random)
        {
            if (!System.IO.File.Exists("save\\auto\\room1.xml"))
            {
                GenerateMaps();
            }

            string path = "room1.xml";
            if (File.Exists("save\\auto\\GameData"))
                path = File.ReadAllText("save\\auto\\GameData");
            if (path.IndexOf(Environment.NewLine) > 0)
            {
                path = path.Substring(0, path.IndexOf(Environment.NewLine));
            }
            if (File.Exists("save\\auto\\saved" + (string)path))
                _map = new Map(this, "saved" + (string)path);
            else
                _map = new Map(this, (string)path);
        }
Example #19
0
        public AkkaProtocolSpec(ITestOutputHelper helper)
            : base(@"
                    akka.actor.provider = remote
                    akka.test.default-timeout = 1.5 s", helper)
        {
            codec        = new AkkaPduProtobuffCodec(Sys);
            testEnvelope = codec.ConstructMessage(_localAkkaAddress, TestActor, testMsg);
            testMsgPdu   = codec.ConstructPayload(testEnvelope);

            testHeartbeat = new InboundPayload(codec.ConstructHeartbeat());
            testPayload   = new InboundPayload(testMsgPdu);

            config = ConfigurationFactory.ParseString(
                @"akka{
                    remote {

                    transport-failure-detector {
                      implementation-class = ""Akka.Remote.PhiAccrualFailureDetector, Akka.Remote""
                      threshold = 7.0
                      max-sample-size = 100
                      min-std-deviation = 100 ms
                      acceptable-heartbeat-pause = 3 s
                      heartbeat-interval = 1 s
                    }

                    backoff-interval = 1 s

                    require-cookie = off

                    secure-cookie = ""abcde""

                    shutdown-timeout = 5 s

                    startup-timeout = 5 s

                    use-passive-connections = on
                }}").WithFallback(Sys.Settings.Config);
        }
Example #20
0
 public void Notify(IHandleEvent ev)
 {
     Actor.Tell(ev);
 }
Example #21
0
 public void Notify(IHandleEvent ev)
 {
     _handler(ev);
 }
Example #22
0
 public BackgroundEventHandler(IHandleEvent <TEvent> handler, ISubscriptionClient subscriptionClient)
 {
     _handler            = handler;
     _subscriptionClient = subscriptionClient;
 }
Example #23
0
 public void Notify(IHandleEvent ev)
 {
     if (!_gremlinAdapter.ShouldDropInbound(WrappedHandle.RemoteAddress, ev, "handler.notify"))
     {
         _upstreamListener.Notify(ev);
     }
 }
Example #24
0
 protected void NotifyListener(IHandleEvent msg)
 {
     _listener?.Notify(msg);
 }
Example #25
0
 public TestEventHapenedOrderedStreamHandler(IHandleEvent <TestEventHappened> handleOrderCreated)
     : base(handleOrderCreated)
 {
 }
Example #26
0
 protected void NotifyListener(IHandleEvent msg)
 {
     _listener?.Notify(msg);
 }
Example #27
0
 protected OrderedStreamHandler(IHandleEvent <TEventType> handleOrderCreated)
 {
     _handleOrderCreated = handleOrderCreated;
     _stream             = GetStreamInfo();
 }
Example #28
0
 /// <summary>
 /// Notify the Actor about an <see cref="IHandleEvent"/> message.
 /// </summary>
 /// <param name="ev">The <see cref="IHandleEvent"/> message to notify the Actor about</param>
 public void Notify(IHandleEvent ev)
 {
     Actor.Tell(ev);
 }
 public EventCallback(IHandleEvent receiver, MulticastDelegate @delegate)
 {
     Receiver = receiver;
     Delegate = @delegate;
 }
Example #30
0
 public MatEventCallback(IHandleEvent receiver, Func <EventCallback <T> > sourceEventCallbackFunc)
 {
     _receiver = receiver;
     _sourceEventCallbackFunc = sourceEventCallbackFunc;
 }
Example #31
0
 public IDisposable Subscribe <T>(IHandleEvent <T> handler) where T : IDomainEvent
 {
     return(Subscribe((IObserver <IDomainEvent>)handler));
 }
Example #32
0
 /// <summary>
 /// Constructor for a loading a map from a file
 /// </summary>
 /// <param name="parent">An event handler to pass events to</param>
 /// <param name="filename">Filename of XML-file containing map data</param>
 /// <param name="playerPos">Coordinates of player on map</param>
 public Map(IHandleEvent parent, string filename = "", Backend.Coords playerPos = null)
     : this()
 {
     _parent = parent;
     Load(filename, playerPos, true);
 }
Example #33
0
 public HandleEventAsynchronouslyDecorator(Container container, Func <IHandleEvent <TEvent> > factory)
 {
     _container = container;
     _factory   = factory;
     _handler   = _factory();
 }
Example #34
0
 protected void NotifyListener(IHandleEvent e) => this.listener?.Notify(e);
Example #35
0
 public EventCache(T @event, IHandleEvent <T> handler)
 {
     _event   = @event;
     _handler = handler;
 }
 public void Register(IHandleEvent handler)
 {
     lock(_eventList)
     _eventList.Add(handler);
 }