Exemplo n.º 1
0
        public void Initialize()
        {
            HTTPConfigurationProvider configurationProvider = new HTTPConfigurationProvider();
            string path = Path.Combine(HostingEnvironment.MapPath("~/App_Data"), "Correspondence");

            _community = new Community(FileStreamStorageStrategy.Load(path))
                         .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(configurationProvider))
                         .Register <CorrespondenceModel>()
                         .Subscribe(() => _conference)
            ;
            _community.ClientApp = false;

            string conferenceId = ConfigurationManager.AppSettings["ConferenceID"];

            if (string.IsNullOrEmpty(conferenceId))
            {
                conferenceId = CommonSettings.ConferenceID;
            }
            _conference = _community.AddFact(new Conference(conferenceId));

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Resume in 5 minutes if there is an error.
            Timer synchronizeTimer = new Timer();

            synchronizeTimer.Elapsed += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = 5.0 * 60.0 * 1000.0;
            synchronizeTimer.Start();

            // And synchronize on startup.
            _community.BeginSending();
            _community.BeginReceiving();
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            HTTPConfigurationProvider configurationProvider = new HTTPConfigurationProvider();
            string path = Path.Combine(HostingEnvironment.MapPath("~/App_Data"), "Correspondence");
            _community = new Community(FileStreamStorageStrategy.Load(path))
                .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(configurationProvider))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _conference)
                ;
            _community.ClientApp = false;

            string conferenceId = ConfigurationManager.AppSettings["ConferenceID"];
            if (string.IsNullOrEmpty(conferenceId))
                conferenceId = CommonSettings.ConferenceID;
            _conference = _community.AddFact(new Conference(conferenceId));

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Resume in 5 minutes if there is an error.
            Timer synchronizeTimer = new Timer();
            synchronizeTimer.Elapsed += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = 5.0 * 60.0 * 1000.0;
            synchronizeTimer.Start();

            // And synchronize on startup.
            _community.BeginSending();
            _community.BeginReceiving();
        }