예제 #1
0
파일: Chat.cs 프로젝트: jimiowns/NextChat
 public Chat(IHubConnectionContext<dynamic> clients)
 {
     if (clients == null) {
     throw new ArgumentNullException("clients");
       }
       Clients = clients;
 }
 private Broadcaster(IHubConnectionContext<dynamic> clients)
 {
     Clients = clients;
     _timer = new Timer(GetLaneLoop, null, TimeSpan.FromSeconds(0), _updateInterval);
     _timer2 = new Timer(GetStatus, null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(3));
     _timer3 = new Timer(GetAverages, null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(15));
 }
예제 #3
0
파일: Ticker.cs 프로젝트: emeraldpiggy/NT
 /// <summary>
 /// Initializes a new instance of the <see cref="Ticker"/> class.
 /// internal for testing purpose
 /// </summary>
 /// <param name="clients">The clients.</param>
 /// <param name="volitility">The volitility.</param>
 public Ticker(IHubConnectionContext <dynamic> clients, double volitility)
 {
     Clients     = clients;
     _volitility = volitility;
     PopulateEquties();
     _timer = new Timer(UpdatePrice, null, _updateInterval, _updateInterval);
 }
예제 #4
0
        private NotificationWatcher(IHubConnectionContext <dynamic> clients)
        {
            Clients = clients;

            //likes watcher

            _likesTableDependency = new SqlTableDependency <Like>(
                ConfigurationManager.ConnectionStrings["defaultConnection"].ConnectionString,
                "Likes", null, null, null, null, DmlTriggerType.All, false);

            _likesTableDependency.OnChanged += SqlLikesTableDependencyChanged;
            _likesTableDependency.OnError   += SqlLikesTableDependencyOnError;
            _likesTableDependency.Start();

            //posts watcher

            _postsTableDependency = new SqlTableDependency <Post>(
                ConfigurationManager.ConnectionStrings["defaultConnection"].ConnectionString,
                "Posts", null, null, null, null, DmlTriggerType.All, false);

            _postsTableDependency.OnChanged += SqlPostsTableDependencyChanged;
            _postsTableDependency.OnError   += SqlLikesTableDependencyOnError;
            _postsTableDependency.Start();

            // friend requests watcher

            _friendRequestsTableDependency = new SqlTableDependency <FriendRequest>(
                ConfigurationManager.ConnectionStrings["defaultConnection"].ConnectionString,
                "FriendRequests", null, null, null, null, DmlTriggerType.All, false);

            _friendRequestsTableDependency.OnChanged += SqlFriendRequestsTableDependencyChanged;
            _friendRequestsTableDependency.OnError   += SqlLikesTableDependencyOnError;
            _friendRequestsTableDependency.Start();
        }
        private LeaderBoardTicker(IHubConnectionContext <dynamic> clients)
        {
            Clients = clients;

            _leaderBoard.Clear();
            var leaderBoards = new List <LeaderBoard>
            {
                new LeaderBoard {
                    teamName = "Team1", Position = "0", PitstopsCrossed = "0", PitstopsRemaining = "0"
                },
                new LeaderBoard {
                    teamName = "Team2", Position = "0", PitstopsCrossed = "0", PitstopsRemaining = "0"
                },
                new LeaderBoard {
                    teamName = "Team3", Position = "0", PitstopsCrossed = "0", PitstopsRemaining = "0"
                },
                new LeaderBoard {
                    teamName = "Team4", Position = "0", PitstopsCrossed = "0", PitstopsRemaining = "0"
                },
                new LeaderBoard {
                    teamName = "Team5", Position = "0", PitstopsCrossed = "0", PitstopsRemaining = "0"
                },
            };

            leaderBoards.ForEach(
                leaderBoard => _leaderBoard.TryAdd(leaderBoard.teamName, leaderBoard));

            //_timer = new Timer(UpdateLeaderBoard, null, _updateInterval, _updateInterval);
        }
예제 #6
0
 HumidityDatasTicker(IHubConnectionContext <dynamic> clients)
 {
     _realTimeDatasService = new NinjectControllerFactory().GetInstance <IHumidityRealTimeDatasService>();
     Clients = clients;
     //定时器
     _timer = new Timer(UpdateHumidityDatas, null, 0, _updateInterval);
 }
        private MonitoringBackgroundWorker(IHubConnectionContext<dynamic> clients)
        {
            Clients = clients;
            _statsToStore = new DataTable();
            _statsToStore.Columns.Add("ServerFriendlyName", typeof(string));
            _statsToStore.Columns.Add("CounterFriendlyName", typeof(string));
            _statsToStore.Columns.Add("CounterValue", typeof(double));
            _statsToStore.Columns.Add("CounterValueDate", typeof(DateTime));


            SandboxDatabaseManagerServiceClient client;

            MyMonitoredServers = new List<MonitoredServer>();
            foreach (var serverToMonitor in MonitoredServers.Instance.ItemsList)
            {
                try
                {
                    client = new SandboxDatabaseManagerServiceClient("NetTcpBinding_ISandboxDatabaseManagerService", serverToMonitor.RemoteAddress);
                    MyMonitoredServers.Add(new MonitoredServer() { Name = serverToMonitor.FriendlyName, Client = client, IsOk = true });
                }
                catch (Exception ex)
                {
                    Log.Error(String.Format("Failed to construct SandboxDatabaseManagerServiceClient for client FriendlyName: {0}, RemotAddress: {1}", serverToMonitor.FriendlyName, serverToMonitor.RemoteAddress), ex);
                }
            }

            backgroundTask = new Task(MonitorAndPushStatistics, TaskCreationOptions.LongRunning);
            backgroundTask.Start();

        }
예제 #8
0
 public EventNotifier(IHubConnectionContext <dynamic> clients, IMappingEngine mapper)
 {
     Contract.Requires <ArgumentNullException>(clients != null, "clients");
     Contract.Requires <ArgumentNullException>(mapper != null, "mapper");
     this.clients = clients;
     this.mapper  = mapper;
 }
예제 #9
0
		private static void InternalSend(IHubConnectionContext<dynamic> clients, string channel, object data)
		{
			var guid = Guid.NewGuid();
			var timestamp = DateTime.Now;

			clients.All.serverMessage(new { guid, timestamp, channel, data });
		}
예제 #10
0
 private void Init()
 {
     connLookup         = new ConnectionLookup();
     proxyLookup        = new ConcurrentDictionary <Guid, IUser>();
     eventHandlerLookup = new ConcurrentDictionary <Guid, ActorEventHandler>();
     hubClients         = GlobalHost.ConnectionManager.GetHubContext <InterfaceHub>().Clients;
 }
예제 #11
0
 public AddClientService(
     ConcurrentDictionary <string, ClientModel> clientsCache,
     IHubConnectionContext <dynamic> clients)
 {
     _clientsCache = clientsCache;
     _clients      = clients;
 }
 private GameWatcher(IHubConnectionContext clients)
 {
     Clients = clients;
     LoadDefaultGames();
     GamesState = FantasyBaseball.GamesState.Paused;
     StartWatcher();
 }
예제 #13
0
        private static void BroadcastScoreUpdateToClients(Shot shot, IHubConnectionContext clients)
        {
            clients.All.ScoreUpdate(shot.Id, shot.ScoreText);

            var shoot = shot.Shoot;

            clients.All.ShootTotalScoreUpdate(shoot.Id, shoot.TotalScore.ToString());

            if (shoot.RegisterCardId.HasValue)
            {
                var registerCard = shoot.RegisterCard;
                clients.All.CompetitorTotalScoreUpdate(registerCard.Id, registerCard.TotalScore.ToString());
                clients.All.RegisterCardSortOrderUpdate(registerCard.Id, registerCard.SortOrder);
            }

            if (shoot.TeamCompetitorId.HasValue)
            {
                var teamCompetitor = shoot.TeamCompetitor;
                clients.All.CompetitorTotalScoreUpdate(teamCompetitor.Id, teamCompetitor.TotalScore.ToString());

                var teamRegisterCard = teamCompetitor.TeamRegisterCard;
                clients.All.TeamRegisterCardDistanceTotalScoreUpdate(teamRegisterCard.Id, shoot.Distance.DisplayValue(),
                                                                     teamRegisterCard.TotalAt(shoot.Distance).ToString());

                clients.All.TeamRegisterCardTotalScoreUpdate(teamRegisterCard.Id, teamRegisterCard.TotalScore.ToString());

                clients.All.TeamRegisterCardSortOrderUpdate(teamRegisterCard.Id, teamRegisterCard.SortOrder);
            }
        }
예제 #14
0
        private Scada(IHubConnectionContext <dynamic> clients)
        {
            try {
                Clients = clients;
                zenOn.Application zapp = null;
                Type acType            = Type.GetTypeFromProgID("zenOn.Application");
                zapp = (zenOn.Application)Activator.CreateInstance(acType, true);
                //zapp = (zenOn.Application)Marshal.GetActiveObject("zenOn.Application");
                //zapp = (zenOn.Application)Marshal.GetActiveObject
                proj = zapp.Projects().Item(0);

                //initialize network
                F.proj = proj;
                F.Generate();
                //F.InfoForQGIS();

                //here we initialize the vehicles
                V.InitializeVehicles();

                //initialize claims
                C.InitializeClaims();


                _timer        = new Timer(CheckVariables, null, _updateInterval, _updateInterval);
                _vehicletimer = new Timer(CheckVehicles, null, _updateIntervalVehicle, _updateIntervalVehicle);
                _claimtimer   = new Timer(CheckClaims, null, _updateIntervalClaim, _updateIntervalClaim);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message + ex.InnerException?.Message);
                return;
            }
        }
예제 #15
0
        public TaxiesBridge(IHubConnectionContext <dynamic> clients)
            : base(clients)
        {
            taxiOnDutyHandler = (s, e) =>
            {
                var districtGroup = e.districtId.ToString();
                Clients.Group(districtGroup).taxiOnDuty(e.taxiDM);
            };

            taxiUpdatedHandler = (s, e) =>
            {
                var districtGroup = e.districtId.ToString();
                Clients.Group(districtGroup).taxiUpdated(e.taxiDM);
            };

            taxiOffDutyHandler = (s, e) =>
            {
                var districtGroup = e.districtId.ToString();
                Clients.Group(districtGroup).taxiOffDuty(e.taxiId);
            };

            TaxiOnDutyEvent  += taxiOnDutyHandler;
            TaxiUpdatedEvent += taxiUpdatedHandler;
            TaxiOffDutyEvent += taxiOffDutyHandler;
        }
예제 #16
0
        private ParkingSingleton(IHubConnectionContext <dynamic> clients)
        {
            Clients = clients;

            log = LogFactory.GetLogger("ParkingSingleton");

            #region 给主页面显示用的
            MainCallback <Location> .Instance().WatchEvent += FileWatch_LctnWatchEvent;

            MainCallback <Device> .Instance().WatchEvent += FileWatch_DeviceWatchEvent;

            MainCallback <ImplementTask> .Instance().WatchEvent += FileWatch_IMPTaskWatchEvent;

            MainCallback <WorkTask> .Instance().WatchEvent += FileWatch_WatchEvent;

            #endregion

            #region 个推
            SingleCallback.Instance().ICCardWatchEvent  += ParkingSingleton_ICCardWatchEvent;
            SingleCallback.Instance().FaultsWatchEvent  += ParkingSingleton_FaultsWatchEvent;
            SingleCallback.Instance().PlateWatchEvent   += ParkingSingleton_PlateWatchEvent;
            SingleCallback.Instance().FixLocsWatchEvent += ParkingSingleton_FixLocsWatchEvent;
            #endregion

            #region 给云服务数据推送的
            CloudCallback.Instance().ParkingRcdWatchEvent += ParkingSingleton_ParkingRcdWatchEvent;
            CloudCallback.Instance().MasterTaskWatchEvent += ParkingSingleton_MasterTaskWatchEvent;
            CloudCallback.Instance().ImpTaskWatchEvent    += ParkingSingleton_ImpTaskWatchEvent;
            CloudCallback.Instance().SendSMSWatchEvent    += ParkingSingleton_SendSMSWatchEvent;
            #endregion
        }
예제 #17
0
 public RemoveClientService(
     ConcurrentDictionary<string, ClientModel> clientsCache,
     IHubConnectionContext<dynamic> clients)
 {
     _clientsCache = clientsCache;
     _clients = clients;
 }
예제 #18
0
 SafetyPreWarningTicker(IHubConnectionContext <dynamic> clients)
 {
     _sfpwrtp = new NinjectControllerFactory().GetInstance <ISafetyPreWarningRealTimePushService>();
     Clients  = clients;
     //定时器
     _timer = new Timer(UpdateStockPrices, null, _updateInterval, _updateInterval);
 }
예제 #19
0
        private DateTimeClock(IHubConnectionContext <dynamic> clients)
        {
            Clients = clients;

            // Se dispara el timer comenzando despúes de 5 segundos, y a partir de allí cada 1 segundo
            _timer = new Timer(UpdateDateTime, null, TimeSpan.FromMilliseconds(5000), TimeSpan.FromMilliseconds(1000));
        }
예제 #20
0
        private void HiLoUpdateJackpotToGroupClient(string jackpotGroup, JackpotData jackpot, string connectionId = null)
        {
            IHubConnectionContext <dynamic> clients = ConnectionHandler.Instance.Clients;

            string[] strArrays = new string[] { connectionId };
            ((dynamic)clients.Group(jackpotGroup, strArrays)).jackpotHiLo(jackpot);
        }
예제 #21
0
 Server(IHubConnectionContext <dynamic> clients, IWorkspaceRepository workspaceRepository)
 {
     VerifyArgument.IsNotNull("clients", clients);
     VerifyArgument.IsNotNull("workspaceRepository", workspaceRepository);
     _clients             = clients;
     _workspaceRepository = workspaceRepository;
 }
예제 #22
0
 private Distributor(IHubConnectionContext clients)
 {
     Clients = clients;
     FillInUseCodes();
     var t = new Task(GetPrice);
     t.Start();
 }
예제 #23
0
        private StockTicker(IHubConnectionContext <dynamic> clients)
        {
            Clients = clients;

            _stocks.Clear();
            var stocks = new List <Models.Stock>
            {
                new Models.Stock {
                    Symbol = "IBOV", Price = 74.31m
                },
                new Models.Stock {
                    Symbol = "PETR4", Price = 11.31m
                },
                new Models.Stock {
                    Symbol = "VALE3", Price = 22.31m
                },
                new Models.Stock {
                    Symbol = "USIM5", Price = 4.31m
                },
                new Models.Stock {
                    Symbol = "JBSS3", Price = 21.31m
                },
                new Models.Stock {
                    Symbol = "APPL", Price = 578.18m
                },
                new Models.Stock {
                    Symbol = "GOOG", Price = 570.30m
                }
            };

            stocks.ForEach(stock => _stocks.TryAdd(stock.Symbol, stock));

            _timer = new Timer(UpdateStockPrices, null, _updateInterval, _updateInterval);
        }
예제 #24
0
        private AssetsEventsService(IHubConnectionContext <dynamic> clients)
        {
            System.Diagnostics.Trace.TraceInformation("AssetsEventsService: initialize");

            Clients = clients;

            initializeDeskInfoCol();

            string connectionString = ConfigurationManager.ConnectionStrings["Microsoft.ServiceBus.ConnectionString"].ConnectionString;
            string topic            = ConfigurationManager.AppSettings["Microsoft.ServiceBus.Topic"];
            string subscription     = ConfigurationManager.AppSettings["Microsoft.ServiceBus.Subscription"];

            _serviceBusClient = SubscriptionClient.CreateFromConnectionString(connectionString, topic, subscription, ReceiveMode.ReceiveAndDelete);

            _serviceBusClient.OnMessage((message) =>
            {
                try
                {
                    // Process message from subscription.
                    var assetsFromServiceBus = JsonConvert.DeserializeObject <AssetServiceBus>(message.GetBody <string>());
                    updateAssetState(assetsFromServiceBus.logicalName, assetsFromServiceBus.state, assetsFromServiceBus.time);
                }
                catch (Exception)
                {
                    // Indicates a problem, unlock message in subscription.
                    System.Diagnostics.Trace.TraceError("AssetsEventsService: can't read message from topic");
                }
            });
        }
예제 #25
0
 private TickDataService(IHubConnectionContext <dynamic> clients)
 {
     Clients       = clients;
     tickData      = GenerateTestData();
     lastTickIndex = tickData.Length - 1;
     timer         = new Timer(Update, null, 1000, 1000);
 }
예제 #26
0
        public ChartController(IHubConnectionContext <dynamic> clients)
        {
            Clients = clients;
            MethodDelegate metho = new MethodDelegate(this.start);

            metho.BeginInvoke(null, null);
        }
 private GameWatcher(IHubConnectionContext clients)
 {
     Clients = clients;
     LoadDefaultGames();
     GamesState = FantasyBaseball.GamesState.Paused;
     StartWatcher();
 }
예제 #28
0
        private StockTicker(IHubConnectionContext <dynamic> clients)
        {
            Clients = clients;

            _stocks.Clear();
            var stocks = new List <Stock>
            {
                new Stock {
                    Symbol = "MSFT", Price = 30.31m
                },
                new Stock {
                    Symbol = "APPL", Price = 578.18m
                },
                new Stock {
                    Symbol = "GOOG", Price = 570.30m
                }
            };

            stocks.ForEach(stock => _stocks.TryAdd(stock.Symbol, stock));

            _timer = new Timer(UpdateStockPrices, null, _updateInterval, _updateInterval);

            _votes.Clear();
            votes = new List <Vote>();
        }
예제 #29
0
        private LiveBetsBase(IHubConnectionContext <dynamic> clients)
        {
            Clients          = clients;
            _shortMatchCodes = new Dictionary <string, SavedMatch>();
            gameToSave       = new List <Game>();
            //the controller below is for testing please comment it initailisation to save server resources
            myController    = new MyController();
            myApiController = new MatchController();

            _gamesWithLiveScoresAndOdds.Clear();

            cc          = new CustomController();
            BetDatabase = cc.BetDatabase;
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Important, please take caution!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
            // firt check if there are some games in the db then populate their MatchNo's in memeory to avoid duplicate ShortCodes
            setInitialGamesFromDb();
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
            _liveBetUrls = new List <LiveBetSource>
            {
                new LiveBetSource
                {
                    Name = "Scores",
                    Url  = "http://www.goalserve.com/getfeed/d1aa4f5599064db8b343090338221a49/soccernew/inplay"
                },
                new LiveBetSource
                {
                    Name = "Odds",
                    Url  = "http://www.goalserve.com/getfeed/d1aa4f5599064db8b343090338221a49/lines/soccer-inplay"
                }
            };

            GetchAllGamesFromServiceProvider().Wait();
            _timer = new Timer(UpdateGames, null, _updateInterval, _updateInterval);
        }
예제 #30
0
 private GameHandler(IHubConnectionContext <dynamic> clients)
 {
     _jackpotTimer    = new Timer(UpdateJackpotTimer, null, 2000, 5000);
     _jackpotGoldList = new ConcurrentDictionary <long, long>();
     _jackpotCoinList = new ConcurrentDictionary <long, long>();
     Clients          = clients;
 }
예제 #31
0
        private static void InternalSend(IHubConnectionContext <dynamic> clients, string channel, object data)
        {
            var guid      = Guid.NewGuid();
            var timestamp = DateTime.Now;

            clients.All.serverMessage(new { guid, timestamp, channel, data });
        }
예제 #32
0
        private CmdbRepository(IHubConnectionContext clients, IRepositoryAdapter<CmdbGraph<CmdbItem, CmdbDependency>> graphsAdapter, IRepositoryAdapter<CmdbItem> nodesAdapter, IRepositoryAdapter<CmdbDependency> edgesAdapter)
        {
            Clients = clients;
            _graphsAdapter = graphsAdapter;
            _nodesAdapter = nodesAdapter;
            _edgesAdapter = edgesAdapter;

            var applicationCategory = new CmdbItemCategory(1, "Application");
            Categories = new Dictionary<long, CmdbItemCategory> {{applicationCategory.Id, applicationCategory}};

            var applicationTypeAttribute = new CmdbAttributeDefinition {Id = 1, Name = "Application Type", Type = typeof (string), AuthorisedValues = new List<object> {"Desktop", "Service"}};
            var languageAttribute = new CmdbAttributeDefinition { Id = 2, Name = "Language", Type = typeof(List<string>) };
            var operationSystemAttribute = new CmdbAttributeDefinition { Id = 3, Name = "Operating System", Type = typeof(string) };
            var itOwnerAttribute = new CmdbAttributeDefinition { Id = 4, Name = "IT Owner", Type = typeof(string) };
            var urlAttribute = new CmdbAttributeDefinition {Id = 5, Name = "Url Link", Type = typeof (string)};
            var businessOwnerAttribute = new CmdbAttributeDefinition {Id = 6, Name = "Business Owner", Type = typeof (string)};
            var componentVersionAttribute = new CmdbAttributeDefinition {Id = 7, Name = "Version", Type = typeof (string)};
            var criticalityAttribute = new CmdbAttributeDefinition {Id = 8, Name = "Criticality", Type = typeof (string)}; //non critical, critical, mission critical
            var vendorAttribute = new CmdbAttributeDefinition {Id = 9, Name = "Vendor", Type = typeof (bool)};
            //var wikiAttribute = new CmdbAttributeDefinition {Id = 10, Name = "Wiki Url", Type = typeof (string)};
            //var licencesAttribute = new CmdbAttributeDefinition {Id = 8, Name = "Licences", Type = typeof (List<string>)};

            AttributeDefinitions = new Dictionary<long, ICollection<CmdbAttributeDefinition>>();
            AttributeDefinitions[applicationCategory.Id] = new List<CmdbAttributeDefinition>
                {
                    applicationTypeAttribute,
                    languageAttribute,
                    operationSystemAttribute,
                    itOwnerAttribute,
                    urlAttribute,
                    businessOwnerAttribute,
                    componentVersionAttribute,
                };
        }
예제 #33
0
 private SignalRService(IHubConnectionContext <dynamic> clients)
 {
     Clients       = clients;
     _compareLogic = new CompareLogic();
     _dataBase     = new BetDemoAppDbContext();
     _matches      = GetMatchesWithBets();
 }
예제 #34
0
 public Dashboard(IHubConnectionContext <dynamic> clients, DateTime startDateTime, int messageBufferSize = 100)
 {
     _clients           = clients;
     _messages          = new BlockingCollection <Message>();
     _lastBeat          = startDateTime;
     _messageBufferSize = messageBufferSize;
 }
예제 #35
0
파일: Server.cs 프로젝트: Robin--/Warewolf
 Server(IHubConnectionContext<dynamic> clients, IWorkspaceRepository workspaceRepository)
 {
     VerifyArgument.IsNotNull("clients", clients);
     VerifyArgument.IsNotNull("workspaceRepository", workspaceRepository);
     _clients = clients;
     _workspaceRepository = workspaceRepository;
 }
예제 #36
0
        public StockTicker(IHubConnectionContext <dynamic> clients)
        {
            Clients = clients;
            var st = new List <Stock> {
                new Stock("Google")
                {
                    Price = 10.54M
                },
                new Stock("Apple")
                {
                    Price = 12.34M
                },
                new Stock("BaiDu")
                {
                    Price = 6.04M
                },
                new Stock("HuaWei")
                {
                    Price = 11.04M
                }
            };

            stocks.Clear();
            st.ForEach(p => stocks.TryAdd(p.Symbol, p));
        }
예제 #37
0
        // In a Hub class there is an API fo calling client methods but this class doesn't.
        // Hence this class needs to get the SignalR context instance for the StockTickerHub class to call methods on clients.
        public StockTicker(IHubConnectionContext <dynamic> clients)
        {
            Clients = clients;

            _stocks.Clear();
            var stocks = new List <Stock>
            {
                new Stock {
                    Symbol = "MSFT", Price = 30.31m
                },
                new Stock {
                    Symbol = "APPL", Price = 578.18m
                },
                new Stock {
                    Symbol = "GOOG", Price = 570.30m
                }
            };

            // _stocks sample be like : {"MSFT", stock object}
            stocks.ForEach(stock => _stocks.TryAdd(stock.Symbol, stock));

            // TImer object periodically calls methods that update stock at random.
            // Passes parameter state as null.
            _timer = new Timer(UpdateStockPrices, null, _updateInterval, _updateInterval);
        }
예제 #38
0
        private PKTicker(IHubConnectionContext <dynamic> clients)
        {
            Clients = clients;

            _pkInfo = GetCurrentPKInfo();

            _timer = new Timer(UpdatePKInfo, null, _updateInterval, _updateInterval);
        }
예제 #39
0
        private RealTimeRequestCountEmitter(IHubConnectionContext clients, IDocumentStore store)
        {
            Clients = clients;

            _timer = new Timer(QueryNewUsages, null, _updateInterval, _updateInterval);

            DocumentStore = store;
        }
        private ProcessingJobs(IHubConnectionContext <object> clients)
        {
            Clients = clients;

            EventAggregator.JobStatusChanged += EventAggregator_JobStatusChanged;
            EventAggregator.JobCompleted     += EventAggregator_JobCompleted;
            EventAggregator.JobCountFound    += EventAggregator_JobCountFound;
        }
 private CacheService(IHubConnectionContext<dynamic> clients)
 {
     Clients = clients;
     _caches.Clear();
     var caches = CacheManager.GetAllCaches();
     caches.ToList().ForEach(cache => _caches.TryAdd(string.Empty, cache));
     _timer = new Timer(UpdateCaches, null, 1000, 1000);
 }
예제 #42
0
 private AtmsClientBroadcaster(IHubConnectionContext<dynamic> clients)
 {
     Clients = clients;
     ListDbNotifier = DbNotifier.ListInstances;
     foreach (var dbt in ListDbNotifier)
     {
         dbt.OnNewChange += SendCashLevels;
     }
 }
        private SingleTonConnection(IHubConnectionContext<dynamic> clients)
        {
            Clients = clients;

            if (_timer == null)
                _timer = new Timer(licenseCheck, null, _checkInterval, _checkInterval);

            _processSwitch = true;
        }
예제 #44
0
		private ContextStateFeeder(IHubConnectionContext<dynamic> clients)
        {
            Clients = clients;

			UpdateContextStatus(null);
			
			_timer = new Timer(UpdateContextStatus, null, _updateInterval, _updateInterval);

        }
        public GameBroadcaster(IHubConnectionContext<dynamic> clients)
        {
            JsonConvert.SerializeObject(typeof(IGameState), Formatting.None, new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            Clients = clients;
        }
예제 #46
0
 public PbxBroadcaster(
     IHubConnectionContext<dynamic> clients, 
     IPbxListener pbxListener, 
     IRepository<PbxEventCache> pbxEventCachesRepository
     )
 {
     mClients = clients;
     mPbxListener = pbxListener;
     mPbxEventCachesRepository = pbxEventCachesRepository;
 }
예제 #47
0
        public ForecastingDataBroadcaster(IHubConnectionContext clients)
        {
            if (clients == null)
            {
                throw new ArgumentNullException("clients");
            }

            Clients = clients;
            _runningForecasts = new ConcurrentDictionary<string, ActiveForecast>();
        }
예제 #48
0
        public ListLogsDirectorTests()
        {
            _eventBus = A.Fake<IEventBus>();
            _runtimeClient = A.Fake<Server.Hubs.IRuntimeClient>();
            _runtimeClientConnectionContext = A.Fake<IHubConnectionContext<Server.Hubs.IRuntimeClient>>();
            _runtimeClientContext = A.Fake<IHubContext<Server.Hubs.IRuntimeClient>>();

            A.CallTo(() => _runtimeClientContext.Clients).Returns(_runtimeClientConnectionContext);
            A.CallTo(() => _runtimeClientConnectionContext.Group(A<string>.Ignored, A<string[]>.Ignored)).Returns(_runtimeClient);
        }
예제 #49
0
        public static void Initialize()
        {
            clients = GlobalHost.ConnectionManager.GetHubContext<Relay>().Clients;

            client = new HubClient();
            proxy  = Task.Run(()=> HubObserverFactory.CreateObjectReference(client)).Result;

            Task.Run(() => Subscribe())
                .Wait();

            Task.Run(() => Resubscribe());
        }
예제 #50
0
        public static void Initialize()
        {
            clients = GlobalHost.ConnectionManager.GetHubContext<Relay>().Clients;
            
            observer = Task.Run(() => Observer.Create()).Result;
            observer.Subscribe(On);

            Task.Run(() => Subscribe())
                .Wait();

            Task.Run(() => Resubscribe());
        }
예제 #51
0
        private BoxScore(IHubConnectionContext<dynamic> clients)
        {
            Clients = clients;

            _games.Clear();
            var games = new List<Game>
            {
                new Game("pitstl", 0, true, "PIT", "STL", 0, 0, 0, 0, 0, 0, 0),
                new Game("wshphl", 0, true, "WSH", "PHL", 0, 0, 0, 0, 0, 0, 0),
                new Game("texbal", 0, true, "TEX", "BAL", 0, 0, 0, 0, 0, 0, 0)
            };
            games.ForEach(game => _games.TryAdd(game.Id, game));
        }
예제 #52
0
 private EmotivServer(IHubConnectionContext<dynamic> clients)
 {
     Clients = clients;
     var cont = new EmotivController.Data.EmotivController();
     if (!_controllers.TryAdd(cont.Name, cont))
     {
         Debug.Assert(false);
     }
     else
     {
         Debug.WriteLine("Controller {0} added to collection.", cont.Name);
     }
 }
예제 #53
0
      private StockTicker(IHubConnectionContext<dynamic> clients)
      {
         Clients = clients;
         var unitWork = new UnitOfWork();
         stockServices = new StockServices(unitWork);
         stockDescriptionServices = new StockDescriptionServices(unitWork);
         portfolioServices = new PortfolioServices(unitWork);
         db = new ApplicationDbContext();

         timer = new Timer(UpdateStockPrices, null, updateInterval, updateInterval);

         //random = new Random(0);
      }
예제 #54
0
        private NFLStatsUpdate(IHubConnectionContext<dynamic> clients) {

            Clients = clients;

            _playersStats.Clear();
            //try an isLive bool, pull currentweek schedule
            using (var db = new FF()) {
                var currentWeekSchedule = db.NFLGame.Where(g => Convert.ToInt16(g.Week) == currentWeekServ && g.Year == currentYear);
                
                //Compare	DateTime t1,DateTime t2, Less than zero t1 is earlier than t2.Zero t1 is the same as t2.Greater than zero t1 is later than t2.
                foreach (var game in currentWeekSchedule) {
                    var UTCNFLgametime = TimeZoneInfo.ConvertTimeToUtc(game.DateEST);
                    if ((DateTime.Compare(DateTime.UtcNow, UTCNFLgametime)) < 0) { }   //game earlier than local time
                    else { }    //game later
                }

                livePlayerList = db.NFLPlayer.ToList();
            }

            foreach (NFLPlayer n in livePlayerList) {
                //Creating a new StatsYearWeek to track Stats with and connect with NFLPlayer
                StatsYearWeek s = new StatsYearWeek();
                SetSYWToZero(s);
                //Remember im doing this live not for stupid class demo, so ill need to make statid off of player
                s.PlayerID = n.id;
                s.Year = currentYear;     //passed in from where?
                s.Week = currentWeekServ;     //passed in from where?
                s.currentPts = 0;
                string statID = (s.Year.ToString() + s.Week.ToString() + s.PlayerID).ToString();   //YearWeekPlayerID is StatID
                s.id = Convert.ToInt32(statID);

                liveStatsList.Add(s);   //list  
                _playersStats.TryAdd(s.id, s);  //dict
            }

            livePlayerList.Clear();     //empty list

            //make a list of players that got updated and send to updatePlayer?
            //livePlayerList.ForEach(player => _players.TryAdd(player.id, player));

            r = new ReadJSONDatafromNFL("2015101200_gtd.json", "2015101200");
            r2 = new ReadJSONDatafromNFL("2015101108_gtd.json", "2015101108");
            /*****
             * NOTE- For stupid demo I have to null/comment out stats in ReadJSON
             *****/
            r.QuickParseAfterLive();
            r2.QuickParseAfterLive();
            //if timer needed
            //_timer = new Timer(UpdatePlayerStats, null, _updateInterval, _updateInterval);
        }
예제 #55
0
        private StockTicker(IHubConnectionContext clients)
        {
            Clients = clients;

            _stocks.Clear();
            var stocks = new List<Stock>
            {
                new Stock { Symbol = "MSFT", Price = 30.31m },
                new Stock { Symbol = "APPL", Price = 578.18m },
                new Stock { Symbol = "GOOG", Price = 570.30m }
            };
            stocks.ForEach(stock => _stocks.TryAdd(stock.Symbol, stock));

            var timer = new Timer(UpdateStockPrices, null, _updateInterval, _updateInterval);
        }
		private GainCapitalRatesProvider(IHubConnectionContext clients)
		{
			_wrapper = DependencyFactory.Container.Resolve<ILoggerWrapper>();

			_gainCapitalRatesService = DependencyFactory.Container.Resolve<IGainCapitalRatesManager>();
			_gainCapitalRatesService.StartProcessing();

			_customerInfo = DependencyFactory.Container.Resolve<ICustomerInfoProvider>();
			_spreadProvider = DependencyFactory.Container.Resolve<IRatesSpreadService>();

			_updateInterval = TimeSpan.FromMilliseconds(Int32.Parse(ConfigurationManager.AppSettings["UpdateInterval"]));

			_timers = new Dictionary<string, Timer>();

			Clients = clients;
		}
예제 #57
0
        private VariableObserver(IHubConnectionContext<dynamic> clients)
        {
            this.Clients = clients;

            try
            {
                IControl control = IControl.create();
                control.connect(IP_UTEST, 9090);
                Console.WriteLine("Connexion OK !!!");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Connexion NON OK !!!");
            }

            vc = Vs.getVariableController();

            _listDataObs = new List<DataObserver>{
                new DataObserver { DataId=2, PathName = "CODES/CT1_M1_PNT/LiveBit", ValueObs="" }
            };

            _timer = new Timer(UpdateDataObservers, null, _updateInterval, _updateInterval);

            ///=======================================================================================================
            ///Il faut charger les valeurs au moins une fois sinon la librairie n'arrive pas a récupérer le type
            ///Et donc il n'arrive pas à mettre les valeurs à jours   :/
            ///=======================================================================================================
                foreach (DataObserver rowObserver in _listDataObs)
                {

                    DataObserver dObs = readValue3(rowObserver);

                    InjectionVariableStatus status = new InjectionVariableStatus();
                    vc.getInjectionStatus(rowObserver.PathName, status);

                    if (status.state == InjectionStates.InjectionStates_IsSet)
                    {
                        rowObserver.IsForced = true;
                    }
                    else
                    {
                        rowObserver.IsForced = false;
                    }
                }
            ///=======================================================================================================
        }
예제 #58
0
        private Broadcaster(IHubConnectionContext<dynamic> clients)
        {
            Clients = clients;
          //  _timer2 = new Timer(GetStatus, null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(3));
          //  _timer3 = new Timer(GetAverages, null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(15));
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = 15000;
            aTimer.Start();

            aTimer1.Elapsed += new ElapsedEventHandler(OnTimedEvent1);
            aTimer1.Interval = 3;
            aTimer1.Start();

            aTimer2.Elapsed += new ElapsedEventHandler(OnTimedEvent2);
            aTimer2.Interval = 15000;
            aTimer2.Start();

        }
        public void ProcessUrls(IEnumerable<string> links,
                                IHubConnectionContext<dynamic> clients,
                                string roomName,
                                string messageId)
        {

            var resourceProcessor = _kernel.Get<IResourceProcessor>();
            
            var contentTasks = links.Select(resourceProcessor.ExtractResource).ToArray();

            Task.Factory.ContinueWhenAll(contentTasks, tasks =>
            {
                foreach (var task in tasks)
                {
                    if (task.IsFaulted)
                    {
                        Trace.TraceError(task.Exception.GetBaseException().Message);
                        continue;
                    }

                    if (task.Result == null || String.IsNullOrEmpty(task.Result.Content))
                    {
                        continue;
                    }

                    // Update the message with the content

                    // REVIEW: Does it even make sense to get multiple results?
                    using (var repository = _kernel.Get<IJabbrRepository>())
                    {
                        var message = repository.GetMessageById(messageId);

                        // Should this be an append?
                        message.HtmlContent = task.Result.Content;

                        repository.CommitChanges();
                    }

                    // Notify the room
                    clients.Group(roomName).addMessageContent(messageId, task.Result.Content, roomName);
                }
            });
        }
예제 #60
-1
        private StockMonitor(IHubConnectionContext<dynamic> clients)
        {
            Clients = clients;
            _stockService = new StockService();

            _stockDependency = new SqlTableDependency<Stock>(ExchangeConfiguration.ConnectionString, "Stock");
            _stockDependency.OnChanged += _stockDependency_OnChanged;
            _stockDependency.OnError += _tableDependency_OnError;
            _stockDependency.Start();
        }