@Override
	public void run()
	{		
		try 
		{
			/*
			// get login information
			String username = _in.readLine();
			String password = _in.readLine();
			
			String responseMessage;

			if (validateLogin(username, password))
			{
				responseMessage = "ok";
			}
			else
			{
				responseMessage = "nok";
			}

			responseMessage = "ok";
			
			_clientInfo.getSender().sendMessage(responseMessage);
			*/
			
			while (!isInterrupted())
			{
				String message = _in.readLine();
				if (message == null)
				{
					// if the received message is null, it means that the
					// client was closed, so there is no need to listen
					// for anymore messages.
					break;
				}
				
				System.out.println("received message: " + message);
				
				JSONObject json = JSONObject.fromObject(message);
				
				switch (json.getInt("type")) {
				case JSON_TYPE_LOGIN:
					System.out.println("JSON_TYPE_LOGIN");
					_clientInfo.setId(json.getString("id"));
					break;
				case JSON_TYPE_MAKE_ROOM:
					System.out.println("JSON_TYPE_MAKE_ROOM");
					int groupNo = _serverDispatcher.makeRoom();
					_clientInfo.setGroupNumber(groupNo);
					break;
				case JSON_TYPE_JOIN:
					System.out.println("JSON_TYPE_JOIN");
					_clientInfo.setGroupNumber(json.getInt("group"));
					//if 2인용 게임이라면 여기서 start
					break;
				case JSON_TYPE_MESSAGE:
					System.out.println("JSON_TYPE_MESSAGE");
					break;
				default:
					break;
				}
				
				
				// forward the received message to the ServerDispatcher object
				_serverDispatcher.dispatchMessage(_clientInfo, message);
			}
		} 
		catch (IOException e) 
		{
		       // error reading from the socket
		}
		
		// communication ended, so interrupt the sender too
		_clientInfo.getSender().interrupt();
		
		// also delete the current client from the ServerDispatcher clients list.
		_serverDispatcher.deleteClient(_clientInfo);
	}