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


C# Publisher类代码示例

本文整理汇总了C#中Publisher的典型用法代码示例。如果您正苦于以下问题:C# Publisher类的具体用法?C# Publisher怎么用?C# Publisher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: welcome

 public override void welcome(Publisher publisher, SubscriberStub subStub)
 {
     if (Greeter != null)
     {
         Greeter.Welcome(TypedPublisher, subStub);
     }
 }
开发者ID:0790486,项目名称:umundo,代码行数:7,代码来源:GreeterDecorator.cs

示例2: Run

        private static void Run()
        {
            using (var countdown = new CountdownEvent(2))
            {
                var subscriber = new Subscriber(MqttBrokerAddress, MqttBrokerPort);
                subscriber.Subscribe(Topic.Hello, Topic.Goodbye);
                subscriber.OnMessage += (topic, payload) =>
                {
                    if (topic == Topic.Hello)
                    {
                        var msg = JsonConvert.DeserializeObject<HelloMessage>(payload);
                        _log.Info("Topic: " + topic);
                        _log.Info("Message: " + msg);
                        countdown.Signal();
                    }
                    else if (topic == Topic.Goodbye)
                    {
                        var msg = JsonConvert.DeserializeObject<GoodbyeMessage>(payload);
                        _log.Info("Topic: " + topic);
                        _log.Info("Message: " + msg);
                        countdown.Signal();
                    }
                };

                var publisher = new Publisher(MqttBrokerAddress, MqttBrokerPort);
                publisher.Publish(Topic.Hello, new HelloMessage() { Name = "John Smith", Date = DateTime.Now });
                publisher.Publish(Topic.Goodbye, new GoodbyeMessage() { Name = "Jane Smith", Date = DateTime.Now });
                countdown.Wait();
            }
        }
开发者ID:yksz,项目名称:samples,代码行数:30,代码来源:Program.cs

示例3: farewell

 public override void farewell(Publisher publisher, SubscriberStub subStub)
 {
     if (Greeter != null)
     {
         Greeter.Farewell(TypedPublisher, subStub);
     }
 }
开发者ID:0790486,项目名称:umundo,代码行数:7,代码来源:GreeterDecorator.cs

示例4: AddPublisher

 public Publisher AddPublisher(Publisher publisher)
 {
     var query = Ninject.Get<InsertPublisherQuery>();
     query.Publisher = publisher;
     query.Execute();
     return publisher;
 }
开发者ID:BlackieLawless,项目名称:Library,代码行数:7,代码来源:BibliographerService.cs

示例5: FireGenericEventArgs

        public void FireGenericEventArgs(
            Publisher publisher,
            Subscriber subscriber)
        {
            const int Value = 42;

            "establish a publisher firing an event with generic event args"._(() =>
                {
                    publisher = new Publisher();
                });

            "establish a subscriber listening to the event of the publisher"._(() =>
                {
                    subscriber = new Subscriber();

                    subscriber.RegisterEvent(publisher);
                });

            "when the publisher fires the event"._(() =>
                {
                    publisher.FireEvent(Value);
                });

            "it should pass value to event handler"._(() =>
                {
                    subscriber.ReceivedValue
                        .Should().Be(Value);
                });
        }
开发者ID:bicole,项目名称:fundamentals,代码行数:29,代码来源:EventArgsSpecifications.cs

示例6: Main

 static void Main(string[] args)
 {
     Publisher publish = new Publisher();
     Subscriber sub = new Subscriber(publish);
     CustemerEventArgs arg = new CustemerEventArgs(3000);
     publish.DoSomething(arg);
 }
开发者ID:naturalna,项目名称:OOPPrinciples,代码行数:7,代码来源:TimerWithEvents.cs

示例7: DeletePublisher

 public Publisher DeletePublisher(Publisher publisher)
 {
     var query = Ninject.Get<DeletePublisherQuery>();
     query.Publisher = publisher;
     query.Execute();
     return publisher;
 }
开发者ID:BlackieLawless,项目名称:Library,代码行数:7,代码来源:BibliographerService.cs

示例8: Main

        static void Main(string[] args)
        {
            /*
             * Make sure this path contains the umundoNativeCSharp.dll!
             */
            SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\umundo\\lib");
            org.umundo.core.Node node = new org.umundo.core.Node();
            Publisher pub = new Publisher("pingpong");
            PingReceiver recv = new PingReceiver();
            Subscriber sub = new Subscriber("pingpong", recv);
            node.addPublisher(pub);
            node.addSubscriber(sub);

            while (true)
            {
                Message msg = new Message();
                String data = "data";
                System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
                byte[] buffer = enc.GetBytes(data);
                msg.setData(buffer);
                msg.putMeta("foo", "bar");
                Console.Write("o");
                pub.send(msg);
                System.Threading.Thread.Sleep(1000);
            }
        }
开发者ID:0790486,项目名称:umundo,代码行数:26,代码来源:Program.cs

示例9: One_Publisher_One_Subscriber_Batch_Broadcast

        public void One_Publisher_One_Subscriber_Batch_Broadcast()
        {
            using (var publisher = new Publisher())
            using (var subscriber = new Subscriber())
            {
                var endpoint = GetEndpoint();
                publisher.Bind(endpoint);
                subscriber.Connect(endpoint);

                Thread.Sleep(100);

                var counterSignal = new CounterSignal(NumberOfMessagesToReceive);
                subscriber.MessageReceived += (s, m) => counterSignal.Increment();

                var messageSent = new TestMessage();

                var batch = new List<TestMessage>();
                for (var i = 0; i < NumberOfMessagesToReceive; i++)
                    batch.Add(messageSent);

                var sw = Stopwatch.StartNew();
                publisher.Broadcast(batch);
                Assert.IsTrue(counterSignal.Wait(TimeOut), "Timeout waiting for message");
                sw.Stop();

                Assert.Inconclusive("{0} elapsed reading {1} messages ({2:N0} per second)", sw.Elapsed, NumberOfMessagesToReceive, NumberOfMessagesToReceive / sw.Elapsed.TotalSeconds);
            }
        }
开发者ID:tleviathan,项目名称:redfoxmq,代码行数:28,代码来源:PublisherSubscriberBenchmarks.cs

示例10: FrameUiMonitor

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="publisher">Frame publisher instance</param>
 /// <param name="dispatcher">Dispatcher instance used to show frame canvas thread</param>
 /// <param name="screen">Canvas to draw image on</param>
 public FrameUiMonitor(Publisher<IFrame> publisher, Dispatcher dispatcher, System.Windows.Controls.Canvas screen)
     : base(publisher)
 {
     _dispatcher = dispatcher;
     _canvas = screen;
     _imageBrush = new ImageBrush();
 }
开发者ID:djjosse,项目名称:Foosbot,代码行数:13,代码来源:FrameUiMonitor.cs

示例11: welcome

 /// <summary>
 /// Welcomes the specified publisher.
 /// </summary>
 /// <param name="pub">The publisher.</param>
 /// <param name="subStub">The subscriber stub.</param>
 public override void welcome(Publisher pub, SubscriberStub subStub)
 {
     Message greeting = Message.toSubscriber(subStub.getUUID());
     greeting.putMeta("participant", Username + ";" + Globals.Score.ToString());
     greeting.putMeta("subscriber", Globals.sub.getUUID());
     pub.send(greeting);
 }
开发者ID:faisalpk29,项目名称:TK3-Projects,代码行数:12,代码来源:FlyHunterGreeter.cs

示例12: Main

 static void Main()
 {
     Publisher eventPublisher = new Publisher();
     new Subscriber("Pesho", eventPublisher);
     new Subscriber("Gosho", eventPublisher);
     eventPublisher.RaiseSampleEvent();
 }
开发者ID:ivanvasilev,项目名称:Telerik-Academy-Homeworks,代码行数:7,代码来源:EventsTest.cs

示例13: Main

        public static void Main()
        {
            var serverAddress = ConfigurationManager.AppSettings.Get("ServerAddress");
            var serverPort = int.Parse(ConfigurationManager.AppSettings.Get("ServerPort"));

            var clientAddress = ConfigurationManager.AppSettings.Get("ClientAddress");
            var clientPort = int.Parse(ConfigurationManager.AppSettings.Get("ClientPort"));

            var cs = new UdpClientServer();
            var serverChannel = new UdpCommunicationChannel(cs, new ChannelConfig { Address = serverAddress, Port = serverPort });
            var clientChannel = new UdpCommunicationChannel(cs, new ChannelConfig { Address = clientAddress, Port = clientPort });

            _userService = new GitHubUserSearchService(new HttpClientFactory());
            _githubBrowser = new GithubBrowser(new HttpClientFactory());

            var userListener = new Listener<UserQuery, UserResponse>(clientChannel, serverChannel);
            userListener.ListenObservable(GetUser);

            var repoListener = new Listener<RepoQuery, RepoResponse>(clientChannel, serverChannel);
            repoListener.ListenObservable(GetRepo);

            var favListener = new Listener<FavQuery, FavResponse>(clientChannel, serverChannel);
            favListener.ListenObservable(AddToFav);

            var publisher = new Publisher<RepoNotification>(serverChannel);
            _githubBrowser.NewCommitsFeed
                .Select(c => new RepoNotification { Commit = c })
                .Subscribe(publisher);

            Console.ReadLine();
        }
开发者ID:pgdotnet,项目名称:RxWorkshop,代码行数:31,代码来源:Program.cs

示例14: Handlers_Can_Be_Unsubscribed

        public void Handlers_Can_Be_Unsubscribed()
        {
            var pub = new Publisher();
            var calledSubscribers = new List<int>();
            var sub1 = new InstanceSubscriber(1, pub, calledSubscribers.Add);
            var sub2 = new InstanceSubscriber(2, pub, calledSubscribers.Add);
            StaticSubscriber.FooWasRaised = false;
            StaticSubscriber.Subscribe(pub);

            // Make sure they really were subscribed
            pub.Raise();
            calledSubscribers.Should().Equal(1, 2);
            StaticSubscriber.FooWasRaised.Should().BeTrue();

            calledSubscribers.Clear();
            sub1.Unsubscribe(pub);
            pub.Raise();
            calledSubscribers.Should().Equal(2);

            StaticSubscriber.FooWasRaised = false;
            StaticSubscriber.Unsubscribe(pub);
            pub.Raise();
            StaticSubscriber.FooWasRaised.Should().BeFalse();

            calledSubscribers.Clear();
            sub2.Unsubscribe(pub);
            pub.Raise();
            calledSubscribers.Should().BeEmpty();

            // Make sure subscribers are not collected before the end of the test
            GC.KeepAlive(sub1);
            GC.KeepAlive(sub2);
        }
开发者ID:thomaslevesque,项目名称:WeakEvent,代码行数:33,代码来源:WeakEventSourceTests.cs

示例15: publisher_can_bind_multiple_different_endpoints

 public void publisher_can_bind_multiple_different_endpoints()
 {
     using (var publisher = new Publisher())
     {
         publisher.Bind(new RedFoxEndpoint("/path1"));
         publisher.Bind(new RedFoxEndpoint("/path2"));
     }
 }
开发者ID:tleviathan,项目名称:redfoxmq,代码行数:8,代码来源:PublisherTests.cs


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