public override ConversationState HandleMessage(Envelope incomingMessage) { Log.Debug($"{nameof(HandleMessage)} (enter)"); ConversationState nextState = null; switch (incomingMessage.Contents) { case StockHistoryResponseMessage m: var stockHistory = m.RecentHistory; Log.Info($"Received stock stream response with {stockHistory.Count} days of recent trading."); nextState = new ConversationDoneState(Conversation, this); var streamConv = new StockStreamRequestConversation(Config.GetInt(Config.BROKER_PROCESS_NUM)); streamConv.SetInitialState(new StockStreamRequestState(Config.GetInt(Config.BROKER_PROCESS_NUM), streamConv)); ConversationManager.AddConversation(streamConv); break; case ErrorMessage m: Log.Error($"Received error message as reply...\n{m.ErrorText}"); nextState = new ConversationDoneState(Conversation, this); break; default: Log.Error($"No logic to process incoming message of type {incomingMessage.Contents?.GetType()}."); Log.Error($"Ending conversation {Conversation.Id}."); nextState = new ConversationDoneState(Conversation, this); break; } Log.Debug($"{nameof(HandleMessage)} (exit)"); return(nextState); }
public override ConversationState HandleMessage(Envelope incomingMessage) { ConversationState nextState = null; switch (incomingMessage.Contents) { case StockHistoryResponseMessage m: Log.Debug($"Received stock history for."); if (TraderModel.Current != null) { TraderModel.Current.StockHistory = m.RecentHistory; } nextState = new ConversationDoneState(Conversation, this); break; case ErrorMessage m: Log.Error($"Received error message as reply...\n{m.ErrorText}"); nextState = new ConversationDoneState(Conversation, this); break; default: Log.Error($"No logic to process incoming message of type {incomingMessage.Contents?.GetType()}. Ignoring message."); break; } return(nextState); }
public override ConversationState HandleMessage(Envelope incomingMessage) { Log.Debug($"{nameof(HandleMessage)} (enter)"); ConversationState nextState = null; switch (incomingMessage.Contents) { case AckMessage m: nextState = new ConversationDoneState(Conversation, this); break; } Log.Debug($"{nameof(HandleMessage)} (exit)"); return(nextState); }
public override ConversationState HandleMessage(Envelope incomingMessage) { Log.Debug($"{nameof(HandleMessage)} (enter)"); ConversationState nextState = null; switch (incomingMessage.Contents) { case ErrorMessage m: Log.Error($"Received error message as reply...\n{m.ErrorText}"); Task.Run(() => LoginHandler?.LoginFailure(m.ErrorText)); nextState = new ConversationDoneState(Conversation, this); ConversationManager.RemoveConversation(Conversation.Id); break; case PortfolioUpdateMessage m: Log.Debug($"Received portfolio for ...\n{m.PortfolioID}"); var port = new Portfolio() { Assets = m.Assets, Username = Username, PortfolioID = m.PortfolioID }; nextState = new ConversationDoneState(Conversation, this); ConversationManager.RemoveConversation(Conversation.Id); Task.Run(() => LoginHandler?.LoginSuccess(port)); break; default: Log.Error($"No logic to process incoming message of type {incomingMessage.Contents?.GetType()}. Ignoring message."); break; } Log.Debug($"{nameof(HandleMessage)} (exit)"); return(nextState); }
public override ConversationState HandleMessage(Envelope incomingMessage) { Log.Debug($"{nameof(HandleMessage)} (enter)"); ConversationState nextState = null; switch (incomingMessage.Contents) { case PortfolioUpdateMessage m: Log.Info($"Received PortfolioUpdate message as reply."); if (TraderModel.Current != null && TraderModel.Current.Portfolio != null) { var updatedPortfolio = new Portfolio(TraderModel.Current.Portfolio) { Assets = m.Assets }; TraderModel.Current.Portfolio = updatedPortfolio; } else { Log.Error("Transaction verified, but no local portfolio to update."); } nextState = new ConversationDoneState(Conversation, this); break; case ErrorMessage m: Log.Error($"Received error message as reply...\n{m.ErrorText}"); TraderModel.Current.PassStatus(m.ErrorText); nextState = new ConversationDoneState(Conversation, this); break; default: Log.Error($"No logic to process incoming message of type {incomingMessage.Contents?.GetType()}. Ignoring message."); break; } Log.Debug($"{nameof(HandleMessage)} (exit)"); return(nextState); }
public override ConversationState HandleMessage(Envelope incomingMessage) { Log.Debug($"{nameof(HandleMessage)} (enter)"); ConversationState nextState = null; switch (incomingMessage.Contents) { //no extra cases, as this state is expected to be end of conversation. case ErrorMessage m: Log.Error($"Received error message as reply...\n{m.ErrorText}"); nextState = new ConversationDoneState(Conversation, this); break; default: Log.Error($"No logic to process incoming message of type {incomingMessage.Contents?.GetType()}. Ignoring message."); break; } Log.Debug($"{nameof(HandleMessage)} (exit)"); return(nextState); }