2012-05-22 3 views
-1
if (serverResponse.contains("PING ")) { 
    writer.write("PONG " + serverResponse.substring(5) + "\r\n"); 
    writer.write("PRIVMSG " + c.getHomechannel() + " :I got pinged!\r\n"); 
    System.out.println("pinged"); 
    writer.flush(); 
} 

자바 IRC 봇 탁구

if (cmd.equalsIgnoreCase("PING")) { 
    TCPRequestManager.sendWrite("PONG " + param); 
    TCPRequestManager.doMsg("c.getHomechannel()", ":I got pinged!"); 
    TCPConnectionManager.getWriter().flush(); 
} 

모두

가 작동하고 나에게 클라이언트가 ping을하고하지만 난 그 사실로 인해 분리에 탁구를 반환 생각하지 않는다라고 메시지를 보내는 것 같다 내가 오전 뭔가 잘못하고 있는거야?

답변

0

PONG message contain a destination일까요? 첫 번째 코드 블록에서 serverResponse.substring(5)이 서버의 서버 이름 인 것 같습니다. 서버에 핑합니다. PONG ~ 서버 ~ irc 서버. 그것은 보이는

PING :a.com   (sent from a.com to b.com) 
PONG b.com :a.com (sent from b.com to a.com) 

:

일반적으로 트랜잭션이 같이 보입니다, a.com는 IRC 서버의 호스트 이름이며, b.com는 연결된 로봇의 호스트 이름입니다 앞의 예제에서 보았 듯이 보내는 내용은 다음과 같습니다.

PING :a.com   (sent from a.com to b.com) 
PONG :a.com   (sent from b.com to a.com, except there's no origin)