Exemple #1
0
        private void UpdateOwnStockPrices(object state)
        {
            string obj      = (string)state;
            string market   = obj.Split(new string[] { "___" }, StringSplitOptions.None)[0];
            string clientId = obj.Split(new string[] { "___" }, StringSplitOptions.None)[1];
            var    data     = new { Summary = new JavaScriptSerializer().Serialize(NinjectWebCommon.GlobalKernal.Get <IUnitOfWork>().MarketRates.GetOwnMarketSummaries().Select(m => new { Bid = m.Bid, Ask = m.Ask, High = m.High.ToString("0.0000"), Low = m.Low.ToString("0.0000"), Volume = m.Volume.ToString("0.0"), MarketName = m.Symbol }).ToList()) };

            _clients.Client(clientId).updateOwnMarket(data);
        }
Exemple #2
0
 public void SendMemo(string memo, string connectionID = null)
 {
     if (string.IsNullOrEmpty(connectionID))
     {
         _clients.All.SendMemo(memo);
     }
     else
     {
         _clients.Client(connectionID).SendMemo(memo);
     }
 }
Exemple #3
0
        private void NotifyNewConnectionOfPlayers(string connectionId)
        {
            var otherPlayers = Players
                               .Values
                               .Where(p => p.Mode == ClientMode.Player || p.Mode == ClientMode.ParticipatingHost)
                               .ToList();

            foreach (Player otherPlayer in otherPlayers)
            {
                _hubConnectionContext
                .Client(connectionId)
                .AddPlayer(otherPlayer.Name, otherPlayer.Score);
            }
        }
Exemple #4
0
 private void notifyUser(string userName, string message)
 {
     if (containsUserName(userName))
     {
         Clients.Client(GetConnectionIdByName(userName)).notify(message);
     }
 }
Exemple #5
0
        /// <summary>
        /// Push to a specific user
        /// </summary>
        /// <param name="who"></param>
        /// <param name="message"></param>
        public static void PushToUser(string who, MessageDTO message, EasyShoppingHub hub)
        {
            IHubConnectionContext <dynamic> clients = GetClients(hub);

            foreach (var connectionId in _connections.GetConnections(who))
            {
                clients.Client(connectionId).addChatMessage(message);
            }
        }
Exemple #6
0
        /// <summary>
        /// Push to a specific user
        /// </summary>
        /// <param name="who"></param>
        /// <param name="message"></param>
        public static void PushToUser(string who, AnnouncementViewModel message, TeduShopHub hub)
        {
            IHubConnectionContext <dynamic> clients = GetClients(hub);

            foreach (var connectionId in _connections.GetConnections(who))
            {
                clients.Client(connectionId).addChatMessage(message);
            }
        }
Exemple #7
0
 public void ReceiveMessage(string userId, string message)
 {
     if (ChatServiceHub.UserConnectionIDs.ContainsKey(userId))
     {
         IHubConnectionContext <dynamic> clients = GlobalHost.ConnectionManager.GetHubContext <ChatServiceHub>().Clients;
         string id = ChatServiceHub.UserConnectionIDs[userId];
         clients.Client(id).receiveMessage(message);
     }
 }
Exemple #8
0
        private void NotifyQuoteSubscribers(object sender, QuotesUpdatedEventArgs eventArgs)
        {
            List <SecurityQuotationViewModel> quotes = eventArgs.UpdatedQuotes;

            lock (_lock)
            {
                foreach (KeyValuePair <string, HashSet <string> > clientCodes in _stocksToUpdate)
                {
                    string           clientId = clientCodes.Key;
                    HashSet <string> codes    = clientCodes.Value;
                    List <SecurityQuotationViewModel> quotesForClient = quotes.Where(q => codes.Contains(q.SecurityCode)).ToList();
                    if (!quotesForClient.IsNullOrEmpty())
                    {
                        _clients.Client(clientId).updateQuote(quotesForClient);
                    }
                }
            }
        }
Exemple #9
0
        public static void Show(string who, EasyShoppingHub hub)
        {
            IHubConnectionContext <dynamic> clients = GetClients(hub);
            IHubContext context = GlobalHost.ConnectionManager.GetHubContext <EasyShoppingHub>();

            foreach (var connectionId in _connections.GetConnections(who))
            {
                clients.Client(connectionId).showAll();
            }
        }
        public AckableQueue <HubClientInvoker> CreateQueue(ConnectionId connectionId)
        {
            AckableQueue <HubClientInvoker> messageQueue = new AckableQueue <HubClientInvoker>();

            messageQueue.OnUnexpectedAckOrderId     += (orderId, cause) => Log.SignalR(LogTag.ManagedQueue_OnUnexpectedAckOrderId, new { connectionId, orderId, cause });
            messageQueue.OnUnexpectedResendOrderIds += (cause) => Log.SignalR(LogTag.ManagedQueue_OnUnexpectedResendOrderIds, new { connectionId, cause });
            messageQueue.OnQueueOverflow            += () => {
                Log.Warn(LogTag.ManagedQueue_OnQueueOverflow, new { connectionId });
                CleanConnection(connectionId);
                Clients.Client(connectionId).ResetClient();
            };

            messageQueue.OnMessages += (messages) => {
                Log.SignalROut(connectionId, messages);
                Clients.Client(connectionId).Do(messages);
            };
            MessageQueues.Add(connectionId, messageQueue);
            return(messageQueue);
        }
        public async Task ExecuteAsync(ClientModel client)
        {
            foreach (var other in _clientsCache.Values)
            {
                _clients.Client(client.Id).Add(Map(other));
            }

            _clientsCache.AddOrUpdate(client.Id, client, (s, existing) => client);

            _clients.All.Add(Map(client));
        }
Exemple #12
0
        private void BroadcastMessage(Guid clientID, string message, string color)
        {
            dynamic client = m_clients.Client(clientID.ToString());

            if (string.IsNullOrEmpty(color))
            {
                color = "white";
            }

            client.broadcastMessage(message, color);
            //m_clients.All.broadcastMessage(message, color);
        }
Exemple #13
0
        private static void Send(string userId, Func <ResponseModel> modelBuilder)
        {
            if (!_UserConnectionIds.ContainsKey(userId))
            {
                return;
            }

            var connectionId = _UserConnectionIds[userId];
            var model        = modelBuilder();

            _Clients.Client(connectionId).showResponse(model);
        }
Exemple #14
0
        /// <summary>
        /// Push to list users
        /// </summary>
        /// <param name="who"></param>
        /// <param name="message"></param>
        public static void PushToUsers(string[] whos, AnnouncementViewModel message, TeduShopHub hub)
        {
            IHubConnectionContext <dynamic> clients = GetClients(hub);

            for (int i = 0; i < whos.Length; i++)
            {
                var who = whos[i];
                foreach (var connectionId in _connections.GetConnections(who))
                {
                    clients.Client(connectionId).addChatMessage(message);
                }
            }
        }
Exemple #15
0
        public static void SendTaskChanged(TaskChangedEventArgs taskChangedDetails, IHubConnectionContext <dynamic> connectionContext)
        {
            Contract.Requires(taskChangedDetails != null);
            Contract.Requires(connectionContext != null);

            foreach (string key in UserConnectionsDictionary.Keys)
            {
                ApplicationUser user = UserConnectionsDictionary[key];
                if (user != null && taskChangedDetails.OwnerUserId == user.Id)
                {
                    connectionContext.Client(key).taskUpdated(new TaskChangeModel(taskChangedDetails));
                }
            }
        }
Exemple #16
0
 private static void DoSend(string conn_id, string message = "")
 {
     clients.Client(conn_id).Message(message);
 }
Exemple #17
0
 public static dynamic Client(string connectionId)
 {
     return(Connector.Client(connectionId));
 }
Exemple #18
0
 public dynamic Client(string connectionId)
 {
     return(_connections.Client(connectionId));
 }
Exemple #19
0
 public async Task ExecuteAsync(ClientStatusModel model)
 {
     _clients.Client(model.Id).Status(Map(model));
 }
Exemple #20
0
        public static void SendUnsorted(int[] numbers, AlgoHub hub, string connId)
        {
            IHubConnectionContext <dynamic> clients = GetClients(hub);

            clients.Client(connId).UpdateChart1(numbers);
        }
Exemple #21
0
 public T Client(string connectionId)
 {
     return(TypedClientBuilder <T> .Build(_dynamicContext.Client(connectionId)));
 }