我正在使用Apache telnet连接到MUD游戏。
这是我的输出:
thufir@dur:~$
thufir@dur:~$
thufir@dur:~$ java -jar NetBeansProjects/Teln/dist/Teln.jar
forgottenkingdoms.org
reading...
. . / *
_ _ _ . . . || .
| |_| |_| | F O R G O T T E N \
|_ _| * . K I N G D O M S .
| | _ _ _ _ _ _ _ _ _
| [] | | |_| |_| |_| |_| |_| |_| |_| | . | `.
| | . | | | `.
| |_ _ _ | ___ | _ _ _| |
| [] | |_| |_| |_| /###\ |_| |_| |_| | [] |
| | | |#####| | | |
| | | |#####| | | |
| | | |#####| | | |
1990 DIKU 1.0 Sebastian Hammer, Michael Seifert, Tom Madsen,
Hans Henrik Staerfeldt, Katja Nyboe
01 Aug 1993 Merc 2.1 Furey, Hatchet, Kahn
01 Dec 1996 SMAUG 1.0 Thoric, Altrag, Blodkai, Narn, Haus, Scryn
1997 SWMUD 2.6 Created by Martin Gallwey and Kenneth McKeever
31 Jul 2009 FKMUD 4.1 By Martin Gallwey & The FK Team
(New accounts should enter 'NEW')
Only one account per player, all characters owned by a player are
stored in a single account.
这是标准的 telnet 输出:
thufir@dur:~$
thufir@dur:~$
thufir@dur:~$ telnet forgottenkingdoms.org 4000
Trying 193.1.99.91...
Connected to forgottenkingdoms.org.
Escape character is '^]'.
F K _ _ _ _ _ _ Michael Seifert,
| V V V V V | DIKU 1.0 Sebastian Hammer,
O I |_ _| 1990 Katja Nyboe, Tom Madsen,
_ _ _| | Hans Henrik Staerfeldt
R N | V V | [] |_ _ Merc 2.1 Created by: Furey, Kahn,
|_ | | V | 01 Aug 1993 Hatchet
G G _ _ _|_ _| | /
| V V V V | [] | / F O R G O T T E N
O D |_ _| |/ K I N G D O M S
| | | |
T O | [] | | | SMAUG 1.0 Thoric, Altrag, Blodkai,
_ _|_ _ _|_| |_ _ 01 Dec 96 Narn, Haus, Scryn
T M | V V V V V V |
| ___ | SWMUD 2.6 Martin Gallwey,
E S | /|||\ | 1997 Kenneth McKeever
| ||||| |
N | ||||| | FKMud 4.0. Martin Gallwey
| ||||| | 29 Nov 2007 Christophe Leclere
| ||||| |
| ||||| | FKMud 4.1 Martin Gallwey
| ||||| | 31 Jul 2009 and the FK Team
| ||||| |
/ / \ \ See help version in game for
full version history
(New accounts should enter 'NEW')
Only one account per player, all characters owned by a player are
stored in a single account.
Enter your ACCOUNT name (not your character name):
我认为,这是因为线的处理方式StreamReader
:
package teln;
import static java.lang.System.out;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class StreamReader {
private String prompt = "/[#]/";
private LineParser lp;
Connection c;
public StreamReader(Connection c) throws IOException, InterruptedException {
this.c = c;
lp = new LineParser(c);
readInputStream();
c.login();
}
private void readInputStream() throws IOException, InterruptedException {
out.println("reading...");
InputStream inputStream = c.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(inputStreamReader);
String line = br.readLine();
while (line != null) { //never terminates...
sb.append(line);
line = br.readLine();
lp.parseLine(line);
}
}
public void setPrompt(String prompt) {
this.prompt = prompt; //need to determine EOL somehow...
}
}
我相当肯定它while (line != null) {
是readInputStream
有问题的。我认为并非每条线都通过了。