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); }
public void SendMemo(string memo, string connectionID = null) { if (string.IsNullOrEmpty(connectionID)) { _clients.All.SendMemo(memo); } else { _clients.Client(connectionID).SendMemo(memo); } }
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); } }
private void notifyUser(string userName, string message) { if (containsUserName(userName)) { Clients.Client(GetConnectionIdByName(userName)).notify(message); } }
/// <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); } }
/// <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); } }
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); } }
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); } } } }
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)); }
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); }
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); }
/// <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); } } }
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)); } } }
private static void DoSend(string conn_id, string message = "") { clients.Client(conn_id).Message(message); }
public static dynamic Client(string connectionId) { return(Connector.Client(connectionId)); }
public dynamic Client(string connectionId) { return(_connections.Client(connectionId)); }
public async Task ExecuteAsync(ClientStatusModel model) { _clients.Client(model.Id).Status(Map(model)); }
public static void SendUnsorted(int[] numbers, AlgoHub hub, string connId) { IHubConnectionContext <dynamic> clients = GetClients(hub); clients.Client(connId).UpdateChart1(numbers); }
public T Client(string connectionId) { return(TypedClientBuilder <T> .Build(_dynamicContext.Client(connectionId))); }