首先,我承认我是新鲜事,我很可能被遗忘在某个地方选择正确的变量,但我的Googling却失败了我,我不知道要做什么,因此我希望得到一些帮助。
而且,我所做的区别只是安卡拉卡特施尔。 更确切地说,在信息中:
@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 + "
");
else
c.write("[you] " + request + "
");
}
if (request.equalsIgnoreCase("bye"))
e.getChannel().close();
}
如果我发出一个正常的信息,即广播,一切都会奏效。 但是,如果我发出指挥,如<clients或
C:Device ManagerApplication ServerExamp
lesSecureChatSecureChatClientin>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]
我不理解,不希望的是,进入纽顿两度。 这似乎非常不合逻辑,令人不快。 在Telnet Example,我没有问题。
感谢你时间。
Regards, Aldrian.