private void OnMessageEntered() { //Can't use Message.Text directly because of object ownership in WPF. var text = Message.Text; if (string.IsNullOrEmpty(text)) { return; } var commands = _server.CurrentSession?.Managers.GetManager <Torch.Commands.CommandManager>(); if (commands != null && commands.IsCommand(text)) { InsertMessage(new TorchChatMessage("Server", text, MyFontEnum.DarkBlue)); _server.Invoke(() => { commands.HandleCommandFromServer(text); }); } else { _server.CurrentSession?.Managers.GetManager <IChatManagerClient>().SendMessageAsSelf(text); } Message.Text = ""; }
private void OnMessageEntered() { //Can't use Message.Text directly because of object ownership in WPF. var text = Message.Text; if (string.IsNullOrEmpty(text)) { return; } var commands = _server.CurrentSession?.Managers.GetManager <Torch.Commands.CommandManager>(); if (commands != null && commands.IsCommand(text)) { InsertMessage(new TorchChatMessage(TorchBase.Instance.Config.ChatName, text, TorchBase.Instance.Config.ChatColor)); _server.Invoke(() => { if (!commands.HandleCommandFromServer(text, InsertMessage)) { InsertMessage(new TorchChatMessage(TorchBase.Instance.Config.ChatName, "Invalid command.", TorchBase.Instance.Config.ChatColor)); return; } }); } else { _server.CurrentSession?.Managers.GetManager <IChatManagerClient>().SendMessageAsSelf(text); } Message.Text = ""; }