public GameClient () {
		client = new Client();
		client.start();

		Network.register(client);

		client.addListener(new Listener() {
			public void connected (Connection connection) {
				Network.RegisterName registerName = new Network.RegisterName();
				registerName.name = name;
				client.sendTCP(registerName);
			}

			public void received (Connection connection, Object object) {
				if (object instanceof Network.UpdateNames) {
					Network.UpdateNames updateNames = (Network.UpdateNames)object;
					chatFrame.setNames(updateNames.names);
					return;
				}

				if (object instanceof Network.ChatMessage) {
					Network.ChatMessage chatMessage = (Network.ChatMessage)object;
					chatFrame.addMessage(chatMessage.text);
					return;
				}
			}

			public void disconnected (Connection connection) {
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						chatFrame.dispose();
					}
				});
			}
		});

		String input = (String) JOptionPane.showInputDialog(null, "Host:", "Connect to chat server", JOptionPane.QUESTION_MESSAGE,
				null, null, "localhost");
		if (input == null || input.trim().length() == 0) System.exit(1);
		final String host = input.trim();

		input = (String)JOptionPane.showInputDialog(null, "Name:", "Connect to chat server", JOptionPane.QUESTION_MESSAGE, null,
				null, "Name");
		if (input == null || input.trim().length() == 0) System.exit(1);
		name = input.trim();

		chatFrame = new ChatFrame(host);
		chatFrame.setSendListener(new Runnable() {
			public void run () {
				//can make it here.
						String input = chatFrame.getSendText();
				Network.ChatMessage chatMessage = new Network.ChatMessage();
				chatMessage.text = input;
				client.sendTCP(chatMessage);
			}
		});
		chatFrame.setCloseListener(new Runnable() {
			public void run () {
				client.stop();
			}
		});
		chatFrame.setVisible(true);

		new Thread("Connect") {
			public void run () {
				try {
					client.connect(5000, host, Network.port);
				} catch (IOException ex) {
					ex.printStackTrace();
					System.exit(1);
				}
			}
		}.start();
	}