public static void main(String[] args) throws Exception 
	{
		Client client = new  Client("146.232.50.251", 3003 );
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		SendHandler sf = new  SendHandler(client); 
		Message msg = new Message();
		
		while (true) {
			String userName = br.readLine();
			client.setName(userName);
			if (client.authenticate(userName)) {
				break;
			}
		}
		ReceiveHandler s = new ReceiveHandler(client);
		s.start();
		while (true) {
			msg = new Message();
			msg.setCommand("send_all");
			msg.setSender(client.getName());
			String message = br.readLine();
			String[] commandCheck = message.split(" ");
			if (commandCheck[0].equals("\\w")) {
				try {
					msg.setCommand("\\w");
					msg.setReceiver(commandCheck[1]);
					msg.setMessage(commandCheck[2]);
					sf.sendMessage(msg);
				} catch (ArrayIndexOutOfBoundsException e) {
					System.out.println("Invalid command \\w receiver message");
				}
			} else if (commandCheck[0].equals("\\l")) {
				msg.setCommand("\\l");
				sf.sendMessage(msg);
			} else if (commandCheck[0].equals("\\e")){
				msg.setType("logout");
				sf.sendMessage(msg);
			} else {
				msg.setMessage(message);
				sf.sendMessage(msg);
			}
			
			
		}
	}