示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Distribox.Network.AntiEntropyProtocol"/> class.
        /// </summary>
        /// <param name="listeningPort">Listening port.</param>
        /// <param name="peerFileName">Peer file name.</param>
        /// <param name="versionControl">Version control.</param>
        public AntiEntropyProtocol(int listeningPort, string peerFileName, VersionControl versionControl)
        {
            // Initialize version control
            this.versionControl = versionControl;

            // Initialize peer list
            this.peers         = PeerList.GetPeerList(peerFileName);
            this.listeningPort = listeningPort;

            // Initialize listener
            this.listener            = new AtomicMessageListener(listeningPort);
            this.listener.OnReceive += this.OnReceiveMessage;

            // Initialize timer to connect other peers periodically
            System.Timers.Timer timer = new System.Timers.Timer(Config.ConnectPeriodMs);
            timer.Elapsed  += this.OnTimerEvent;
            timer.AutoReset = true;
            timer.Enabled   = true;

            // Initialize request manager
            this.requestManager = new RequestManager();

            // Initialize Protocol message factory
            this.messageFactory = new ProtocolMessageFactory();
        }
 /// <summary>
 /// Test the factory.
 /// </summary>
 /// <param name="message">The message.</param>
 public void TestFactory(ProtocolMessage message)
 {
     ProtocolMessageFactory factory = new ProtocolMessageFactory();
     ProtocolMessage message2 = factory.CreateMessage(new ProtocolMessageContainer(message));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="Distribox.Network.AntiEntropyProtocol"/> class.
        /// </summary>
        /// <param name="listeningPort">Listening port.</param>
        /// <param name="peerFileName">Peer file name.</param>
        /// <param name="versionControl">Version control.</param>
        public AntiEntropyProtocol(int listeningPort, string peerFileName, VersionControl versionControl)
        {
            // Initialize version control
            this.versionControl = versionControl;

            // Initialize peer list
            this.peers = PeerList.GetPeerList(peerFileName);
            this.listeningPort = listeningPort;

            // Initialize listener
            this.listener = new AtomicMessageListener(listeningPort);
            this.listener.OnReceive += this.OnReceiveMessage;

            // Initialize timer to connect other peers periodically
            System.Timers.Timer timer = new System.Timers.Timer(Config.ConnectPeriodMs);
            timer.Elapsed += this.OnTimerEvent;
            timer.AutoReset = true;
            timer.Enabled = true;

            // Initialize request manager
            this.requestManager = new RequestManager();

            // Initialize Protocol message factory
            this.messageFactory = new ProtocolMessageFactory();
        }