@ -8,6 +8,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import envoy.client.*;
|
||||
import envoy.client.util.EnvoyLog;
|
||||
@ -28,6 +29,8 @@ import envoy.schema.User;
|
||||
*/
|
||||
public class Startup {
|
||||
|
||||
private static ChatWindow chatWindow;
|
||||
|
||||
private static final Logger logger = EnvoyLog.getLogger(Startup.class.getSimpleName());
|
||||
|
||||
/**
|
||||
@ -44,6 +47,8 @@ public class Startup {
|
||||
public static void main(String[] args) {
|
||||
Config config = Config.getInstance();
|
||||
|
||||
SwingUtilities.invokeLater(() -> chatWindow = new ChatWindow());
|
||||
|
||||
try {
|
||||
// Load the configuration from client.properties first
|
||||
config.load();
|
||||
@ -82,6 +87,8 @@ public class Startup {
|
||||
return;
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(() -> chatWindow.setVisible(true));
|
||||
|
||||
// Acquire the client user (with ID) either from the server or from the local
|
||||
// database, which triggers offline mode
|
||||
Client client = new Client(config);
|
||||
@ -96,6 +103,10 @@ public class Startup {
|
||||
User clientUser = localDB.getUsers().get(userName);
|
||||
if (clientUser == null) throw new EnvoyException("Could not enter offline mode: user name unknown");
|
||||
client.setSender(clientUser);
|
||||
JOptionPane.showMessageDialog(null,
|
||||
"A connection to the server could not be established. Starting in offline mode.",
|
||||
"Connection error",
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
} catch (Exception e2) {
|
||||
JOptionPane.showMessageDialog(null, e2.toString(), "Client error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(1);
|
||||
@ -125,8 +136,8 @@ public class Startup {
|
||||
|
||||
EventQueue.invokeLater(() -> {
|
||||
try {
|
||||
ChatWindow chatWindow = new ChatWindow(client, localDB);
|
||||
chatWindow.setVisible(true);
|
||||
chatWindow.setClient(client);
|
||||
chatWindow.setLocalDB(localDB);
|
||||
|
||||
try {
|
||||
new StatusTrayIcon(chatWindow).show();
|
||||
|
Reference in New Issue
Block a user