...

int idx = msg.indexOf(" ");

// System.out.println(idx);

int idx_t = msg.indexOf(" ", 4);

// System.out.println(idx_t);


toWhisper = msg.substring(idx + 1, idx_t);

// System.out.println("귓속말 대상 : " + toWhisper); // 귓속말 대상 분리


wsp_str = msg.substring(idx_t + 1);

// System.out.println("귓속말 내용 : " + wsp_str); // 귓속말 내용

Iterator<String> itf = clientMap.keySet().iterator();


while (itf.hasNext()) {

FromWmem = itf.next();

if (FromWmem.contains(user))

user = FromWmem; // mname@rloc

} // 해쉬맵에서 귓속말 보내는 사람 찾음.


} catch (Exception e) {

System.out.println("toWhisper from error : " + e);

}


if(msg.contains("/to "+toWhisper)) {

msg = wsp_str;

}

if(msg.equals("/to " +toWhisper)) {

msg = "고정 귓속말 입니다.";

}

int cnt = 0;

Iterator it = clientMap.keySet().iterator();

try { // 해쉬맵에서 귓속말 받는 사람 찾기


Iterator<String> itt = clientMap.keySet().iterator();

while (itt.hasNext()) {

ToWmem = itt.next();

if (ToWmem.contains(toWhisper))

uTuser = ToWmem; // mname@rloc

} // 해쉬맵에서 귓속말 받는 사람 찾음.


try {


while (it.hasNext()) {

try {

if (uTuser != null) {

PrintWriter it_out = (PrintWriter) clientMap.get(uTuser); // 귓속말 대상

it_out.println(URLEncoder.encode("[" + time.format(today) + "] " + uFname + "의 귓속말 >> " + msg, "UTF-8"));

}

break;

} else {

out.println(URLEncoder.encode("해당 대상이 없습니다.", "UTF-8"));

break;

}

} catch (Exception e) {

System.out.println("예외 toWhisper : " + e);

}


}


} catch (Exception e) {

System.out.println("예외 to : " + e);

}

} catch (Exception e) {

System.out.println("toWhisper to error : " + e);

try {

out.println();

out.println(URLEncoder.encode("★★★귓속말 도움말★★★", "UTF-8"));

out.println(URLEncoder.encode("일회성 귓속말 : /to 대상 내용", "UTF-8"));

out.println(URLEncoder.encode("고정 귓속말 : /to 대상", "UTF-8"));

out.println();

} catch (Exception e2) {

}


}


}



귓속말은 고정귓속말과 일회성귓속말이 있는데 클라이언트 측에서 /to 사용자이름 내용으로 보낸다.

그러므로 그 사용자이름을 HashMap에서 찾아서 Printwriter를 받아 내용을 보내면 된다.

블로그 이미지

허니눈

,