/// <summary> /// Handles a new prompt for this user. /// </summary> /// <param name="newPrompt"></param> public void Prompt(HeldPrompt newPrompt) { if (this.clearingPrompts) { return; } int foundPrompt = -1; lock (this.prompts) { for (int i = 0; i < prompts.Length; i++) { if (this.prompts[i] == null) { foundPrompt = i; this.prompts[i] = newPrompt; break; } } } if (foundPrompt != -1) { StringBuilder builder = new StringBuilder(); builder.Append("New Prompt ").Append(foundPrompt + 1).Append(endOfLine); newPrompt.OnTransition(); this.sendMessage(builder.ToString()); } else { //this.sendMessage("You were too busy to " + TODO ?); newPrompt.Respond(null); } }
/// <summary> /// Forces this connection to log out of the current account and basically reset. /// </summary> public void LogOut() { lock (this.prompts) { ClearPrompts(); mainPrompt = new LoginPrompt(this); } //No need for account.LogOut(), but if there was it would maybe go here. this.LoggedInAccount = null; mainPrompt.OnTransition(); }
public Client(Socket s, int packetSize) { this.socket = s; this.buffer = new byte[packetSize]; this.LastReceived = DateTime.UtcNow; this.inputHandlerTypes.Add(IACHandlerType.Instance); this.TransitionToInputHandler(new DefaultInputHandler()); this.socket.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, receiveData, null); negotiateTelnetMode(TelnetCode.TERMTYPE); this.mainPrompt = new LoginPrompt(this); //TODO: Server intro goes here this.sendMessage("Unnamed EspressoMUD Server"); //TODO: Move to external resource file. mainPrompt.OnTransition(); }
/// <summary> /// Forces this connection to log out of the current MOB, but stay in the account. /// </summary> public void ReturnToLoggedInPrompt() { lock (this.prompts) { if (this.LoggedInAccount == null) { LogOut(); } else { ClearPrompts(); mainPrompt = LoginPrompt.GetLoggedInPrompt(this); mainPrompt.OnTransition(); } } }