当前位置: 首页>>代码示例>>C#>>正文


C# EventStream.Publish方法代码示例

本文整理汇总了C#中Akka.Event.EventStream.Publish方法的典型用法代码示例。如果您正苦于以下问题:C# EventStream.Publish方法的具体用法?C# EventStream.Publish怎么用?C# EventStream.Publish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Akka.Event.EventStream的用法示例。


在下文中一共展示了EventStream.Publish方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ManageSubscriptions

        public void ManageSubscriptions()
        {
            var bus = new EventStream(true);
            bus.Subscribe(TestActor, typeof(M));

            bus.Publish(new M { Value = 42 });
            ExpectMsg(new M { Value = 42 });
            bus.Unsubscribe(TestActor);
            bus.Publish(new M { Value = 43 });
            ExpectNoMsg(TimeSpan.FromSeconds(1));
        }
开发者ID:njimenez,项目名称:akka.net,代码行数:11,代码来源:EventStreamSpec.cs

示例2: ManageSubscriptions

        public void ManageSubscriptions()
        {

            var bus = new EventStream(true);
            bus.StartUnsubscriber(Sys.AsInstanceOf<ActorSystemImpl>());
            bus.Subscribe(TestActor, typeof(M));

            bus.Publish(new M { Value = 42 });
            ExpectMsg(new M { Value = 42 });
            bus.Unsubscribe(TestActor);
            bus.Publish(new M { Value = 43 });
            ExpectNoMsg(TimeSpan.FromSeconds(1));
        }
开发者ID:skotzko,项目名称:akka.net,代码行数:13,代码来源:EventStreamSpec.cs

示例3: ManageLogLevels

        public void ManageLogLevels()
        {
            var bus = new EventStream(false);
            bus.StartDefaultLoggers((ActorSystemImpl)Sys);
            bus.Publish(new SetTarget(TestActor));
            ExpectMsg("OK", TimeSpan.FromSeconds(5));

            verifyLevel(bus, LogLevel.InfoLevel);
            bus.SetLogLevel(LogLevel.WarningLevel);
            verifyLevel(bus, LogLevel.WarningLevel);
            bus.SetLogLevel(LogLevel.DebugLevel);
            verifyLevel(bus, LogLevel.DebugLevel);
            bus.SetLogLevel(LogLevel.ErrorLevel);
            verifyLevel(bus, LogLevel.ErrorLevel);
        }
开发者ID:skotzko,项目名称:akka.net,代码行数:15,代码来源:EventStreamSpec.cs

示例4: ManageSubChannelsUsingClassesAndInterfacesUpdateOnUnsubscribeAll

        public void ManageSubChannelsUsingClassesAndInterfacesUpdateOnUnsubscribeAll()
        {
            var es = new EventStream(false);
            var tm1 = new CC();
            var tm2 = new CCATBT();
            var a1 = CreateTestProbe();
            var a2 = CreateTestProbe();
            var a3 = CreateTestProbe();
            var a4 = CreateTestProbe();

            es.Subscribe(a1.Ref, typeof(AT)).ShouldBeTrue();
            es.Subscribe(a2.Ref, typeof(BT)).ShouldBeTrue();
            es.Subscribe(a3.Ref, typeof(CC)).ShouldBeTrue();
            es.Subscribe(a4.Ref, typeof(CCATBT)).ShouldBeTrue();
            es.Unsubscribe(a3.Ref).ShouldBeTrue();
            es.Publish(tm1);
            es.Publish(tm2);
            a1.ExpectMsg((object)tm2);
            a2.ExpectMsg((object)tm2);
            a3.ExpectNoMsg(TimeSpan.FromSeconds(1));
            a4.ExpectMsg((object)tm2);
            es.Unsubscribe(a1.Ref, typeof(AT)).ShouldBeTrue();
            es.Unsubscribe(a2.Ref, typeof(BT)).ShouldBeTrue();
            es.Unsubscribe(a3.Ref, typeof(CC)).ShouldBeFalse();
            es.Unsubscribe(a4.Ref, typeof(CCATBT)).ShouldBeTrue();
        }
开发者ID:skotzko,项目名称:akka.net,代码行数:26,代码来源:EventStreamSpec.cs

示例5: ManageSubChannelsUsingClasses

        public void ManageSubChannelsUsingClasses()
        {
            var a = new A();
            var b1 = new B1();
            var b2 = new B2();
            var c = new C();
            var bus = new EventStream(false);
            bus.Subscribe(TestActor, typeof(B2));
            bus.Publish(c);
            bus.Publish(b2);
            ExpectMsg(b2);
            bus.Subscribe(TestActor, typeof(A));
            bus.Publish(c);
            ExpectMsg(c);
            bus.Publish(b1);
            ExpectMsg(b1);

            bus.Unsubscribe(TestActor, typeof(B1));
            bus.Publish(c); //should not publish
            bus.Publish(b2); //should publish
            bus.Publish(a); //should publish
            ExpectMsg(b2);
            ExpectMsg(a);
            ExpectNoMsg(TimeSpan.FromSeconds(1));
        }
开发者ID:skotzko,项目名称:akka.net,代码行数:25,代码来源:EventStreamSpec.cs

示例6: ManageSubChannelsUsingClassesAndInterfacesUpdateOnUnsubscribeAll

        public void ManageSubChannelsUsingClassesAndInterfacesUpdateOnUnsubscribeAll()
        {
            var es = new EventStream(false);
            var tm1 = new CC();
            var tm2 = new CCATBT();
            var a1 = TestProbe();
            var a2 = TestProbe();
            var a3 = TestProbe();
            var a4 = TestProbe();

            es.Subscribe(a1.Ref, typeof(AT)).Then(Assert.True);
            es.Subscribe(a2.Ref, typeof(BT)).Then(Assert.True);
            es.Subscribe(a3.Ref, typeof(CC)).Then(Assert.True);
            es.Subscribe(a4.Ref, typeof(CCATBT)).Then(Assert.True);
            es.Unsubscribe(a3.Ref).Then(Assert.True);
            es.Publish(tm1);
            es.Publish(tm2);
            a1.expectMsg(tm2);
            a2.expectMsg(tm2);
            a3.expectNoMsg(TimeSpan.FromSeconds(1));
            a4.expectMsg(tm2);
            es.Unsubscribe(a1.Ref, typeof(AT)).Then(Assert.True);
            es.Unsubscribe(a2.Ref, typeof(BT)).Then(Assert.True);
            es.Unsubscribe(a3.Ref, typeof(CC)).Then(Assert.False);
            es.Unsubscribe(a4.Ref, typeof(CCATBT)).Then(Assert.True);
        }
开发者ID:rmiller1971,项目名称:akka.net,代码行数:26,代码来源:EventStreamSpec.cs

示例7: ManageLogLevels

        public void ManageLogLevels()
        {
          var bus = new EventStream(false);
          bus.StartDefaultLoggers(sys);
          bus.Publish(new SetTarget(testActor));
          expectMsg("OK");

          verifyLevel(bus, LogLevel.InfoLevel);
          bus.SetLogLevel(LogLevel.WarningLevel);
          verifyLevel(bus, LogLevel.WarningLevel);
          bus.SetLogLevel(LogLevel.DebugLevel);
          verifyLevel(bus, LogLevel.DebugLevel);
          bus.SetLogLevel(LogLevel.ErrorLevel);
          verifyLevel(bus, LogLevel.ErrorLevel);

        }
开发者ID:Badmoonz,项目名称:akka.net,代码行数:16,代码来源:EventStreamSpec.cs


注:本文中的Akka.Event.EventStream.Publish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。