コード例 #1
0
ファイル: ClientPump.cs プロジェクト: SmartFire/ShortBus
 /// <summary>
 /// Entry point for subscription events from the server
 /// </summary>
 /// <param name="data">Event data</param>
 public void Consume(ServiceBusEvent data)
 {
     if (Consumer != null)
     {
         Consumer(data);
     }
 }
コード例 #2
0
ファイル: ServerPumpTest.cs プロジェクト: SmartFire/ShortBus
        public void PublishTest()
        {
            ServerPump      target = new ServerPump(); // TODO: Initialize to an appropriate value
            ServiceBusEvent data   = null;             // TODO: Initialize to an appropriate value

            target.Publish(data);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
コード例 #3
0
ファイル: ServerPumpTest.cs プロジェクト: SmartFire/ShortBus
        public void SendMessageTest()
        {
            ServerPump_Accessor target       = new ServerPump_Accessor(); // TODO: Initialize to an appropriate value
            Subscriber          subscription = null;                      // TODO: Initialize to an appropriate value
            ServiceBusEvent     data         = null;                      // TODO: Initialize to an appropriate value

            target.SendMessage(subscription, data);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
コード例 #4
0
 /// <summary>
 /// Send a message to a subscription
 /// </summary>
 /// <param name="subscription">The subscription the message is destined for</param>
 /// <param name="data">The message to send to the subscriber</param>
 void SendMessage(Subscriber subscription, ServiceBusEvent data)
 {
     if (!clients.ContainsKey(subscription.SubscriberId))
     {
         clients.Add(subscription.SubscriberId, ClientFactory.Connect(subscription.Endpoint));
     }
     try
     {
         clients[subscription.SubscriberId].Consume(data);
         Debug.WriteLine("Sent event {0} to client {1}", data.EventName, subscription.SubscriberId);
     }
     catch (EndpointNotFoundException)
     {
         Unsubscribe(subscription.SubscriberId);
     }
 }
コード例 #5
0
ファイル: ClientPump.cs プロジェクト: SmartFire/ShortBus
 /// <summary>
 /// Broadcast an event
 /// </summary>
 /// <param name="data">Event data. SourceSubscriber and MessageSent will be set automatically.</param>
 public void Broadcast(ServiceBusEvent data)
 {
     data.SourceSubscriber = myId;
     data.MessageSent      = DateTime.Now;
     server.Publish(data);
 }
コード例 #6
0
 /// <summary>
 /// Interface method used by clients
 /// </summary>
 /// <param name="data">A message to broadcast</param>
 public void Publish(ServiceBusEvent data)
 {
     Debug.WriteLine("{0} published an event {1} ({2})", data.SourceSubscriber, data.EventName, data.EventId);
     Task.Factory.StartNew(() => Storage.GetSubscribers().ForEach(sub => SendMessage(sub, data)));
     Storage.SubscriberSeen(data.SourceSubscriber);
 }