우선, 저는이 문제에 익숙하지 않고 올바른 변수의 어딘가에 옵션을 설정하는 것을 잊어 버렸을 것입니다. 그러나 인터넷 검색이 실패하고 나는 무엇을해야할지 모르겠다. 그래서 도움이되기를 바랐다.서버가 내 명령에 직접 응답하지 않습니다.
나는 SecureChat 예에서이 작업을 기반으로 한, 그것은 여기에 있습니다 : http://netty.io/docs/unstable/xref/org/jboss/netty/example/securechat/package-summary.html
그리고 내가 만든 한 차이는 단지 SecureChatServerHandler에 있었다. 더 정확하게 messageRecieved 블록 : 나는 방송 점점 정상적인 메시지를 보낼 경우
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
// Convert the message to a string
String request = (String) e.getMessage();
System.out.println("Message recieved: " + request);
if (request.equalsIgnoreCase("clients")) {
channels.write("We currently have: " + channels.size() + " clients");
} else if (request.toLowerCase().equals("koko"))
for (Channel c : channels) {
if (c == e.getChannel())
c.write("HELLO WORLD");
}
else {
// Then send it to all channels, but the current one.
for (Channel c : channels)
if (c != e.getChannel())
c.write("[" + e.getChannel().getRemoteAddress() + "] " + request + "\n");
else
c.write("[you] " + request + "\n");
}
if (request.equalsIgnoreCase("bye"))
e.getChannel().close();
}
는 모든 작동합니다. 그러나 클라이언트 또는 koko과 같은 명령을 보내면 다시 Enter 키를 누르고 빈 메시지를 보낼 때까지 응답이 없습니다. 먼저 응답을받습니다.
C:\Device Manager\Application Server\Examp
les\SecureChat\SecureChatClient\bin>java -jar client.jar 127.0.0.1 8080
UNKNOWN SERVER CERTIFICATE: CN=securechat.example.netty.gleamynode.net, OU=Contr
ibutors, O=The Netty Project, L=Seongnam-si, ST=Kyunggi-do, C=KR
Welcome to Electus secure chat service!
Your session is protected by TLS_DHE_RSA_WITH_AES_128_CBC_SHA cipher suite
You are the 1th user
koko<ENTER>
<PRESS ENTER AGAIN>
HELLO WORLD[you]
clients<ENTER>
<AND ENTER ONCE AGAIN>
We currently have: 1 clients[you]
내가 이해하지 못하고 원치 않는 것은 입력 버튼을 두 번 누르는 것입니다. 그것은 매우 inlogical 것 그것은 자극적이다. 텔넷 예제에 이러한 문제가 없었습니다.
감사합니다.
감사합니다. 알드리안.
일부 테스트를 수행 했는데도 if/else가 없으면 작동하는 것 같습니다. – Aldrian