Ejemplo n.º 1
0
 public void RemoveObserver(IBroadcastChannel channel)
 {
     if (channels.Contains(channel))
     {
         channels.Remove(channel);
     }
 }
Ejemplo n.º 2
0
        public void SetUp()
        {
            _connectionListener    = MockRepository.GenerateMock <IServerConnectionListener>();
            _remoteExecutorFactory = MockRepository.GenerateMock <IRemoteExecutorFactory>();
            _taskScheduler         = MockRepository.GenerateMock <ITaskScheduler>();
            _config = MockRepository.GenerateMock <IServerConfig>();
            _config.Stub(c => c.MaxConnections).Return(10);
            _config.Stub(c => c.RemoteExecutorFactory).Return(_remoteExecutorFactory);
            _config.Stub(c => c.TaskScheduler).Return(_taskScheduler);
            _operationDispatcher = MockRepository.GenerateMock <IOperationDispatcher>();
            _operationDispatcher.Stub(d => d.MessageDispatcher).Return(MockRepository.GenerateMock <IMessageDispatcher>());
            _broadcastChannel = MockRepository.GenerateMock <IBroadcastChannel>();
            _connectionListener.Stub(l => l.BroadcastChannel).Return(_broadcastChannel);
            _broadcastExecutor = MockRepository.GenerateMock <IBroadcastRemoteExecutor>();
            _remoteExecutorFactory.Stub(f => f.CreateBroadcastRemoteExecutor(_broadcastChannel)).Return(_broadcastExecutor);

            _subject = new GenericServerEndpoint(_connectionListener, _config, () => _operationDispatcher);
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            // Get the sender ID from configuration
            string senderId = ConfigurationManager.AppSettings["sender"];

            // Create the sender with the given endpoint configuration
            // Sender is an instance of the sender side of the broadcast application that has opened a channel to mesh
            ChannelFactory <IBroadcastChannel> factory = new ChannelFactory <IBroadcastChannel>("BroadcastEndpoint");

            IBroadcastChannel sender = factory.CreateChannel();

            // Retrieve the PeerNode associated with the sender and register for online/offline events
            // PeerNode represents a node in the mesh. Mesh is the named collection of connected nodes.
            IOnlineStatus ostat = sender.GetProperty <IOnlineStatus>();

            ostat.Online  += new EventHandler(OnOnline);
            ostat.Offline += new EventHandler(OnOffline);

            // Open the sender so that the instance can join the mesh even before the first message is sent
            sender.Open();

            Console.WriteLine("{0} is ready", senderId);
            Console.WriteLine("Press <ENTER> to send annoucements after starting the receivers and going Online");
            Console.ReadLine();
            Console.WriteLine("Sending Announcement 1");
            sender.Announce("Announcement 1");
            Console.WriteLine("Sending Announcement 2");
            sender.Announce("Announcement 2");
            Console.WriteLine("Sending Announcement 3");
            sender.Announce("Announcement 3");
            Console.WriteLine("Press <ENTER> to terminate the sender.");
            Console.ReadLine();

            sender.Close();

            factory.Close();
        }
Ejemplo n.º 4
0
 public void AddObserver(IBroadcastChannel channel)
 {
     channels.Add(channel);
 }
 /// <summary>
 /// Creates broadcast remote executor for given broadcast channel.
 /// </summary>
 /// <param name="channel">Broadcast channel.</param>
 /// <returns>Broadcast executor.</returns>
 public IBroadcastRemoteExecutor CreateBroadcastRemoteExecutor(IBroadcastChannel channel)
 {
     return(new BroadcastRemoteExecutor(channel, _messageFactory));
 }