private void OnSnapshotReady(object sender, NetMQSocketEventArgs e) { string command = snapshotSocket.ReceiveString(); // Currently we only have one type of events if (command == SnapshotProtocol.GetTradessCommand) { var tickers = tickerRepository.GetAllTickers(); // we will send all the tickers in one message foreach (var ticker in tickers) { snapshotSocket.SendMore(JsonConvert.SerializeObject(ticker)); } snapshotSocket.Send(SnapshotProtocol.EndOfTickers); } }
public async Task SubscribeTrades() { contextHolder.TickerHubClients = Clients; var user = ContextUtil.GetUserName(Context); Log.InfoFormat("Received trade subscription from user {0}", user); // add client to the trade notification group await Groups.Add(Context.ConnectionId, TickerGroupName); Log.InfoFormat("Connection {0} of user {1} added to group '{2}'", Context.ConnectionId, user, TickerGroupName); var tickers = tickerRepository.GetAllTickers(); await Clients.Caller.SendTickers(tickers); Log.InfoFormat("Snapshot published to {0}", Context.ConnectionId); }