how to get the "line turnaround" prompt with apache telnet

117 views Asked by At

I'm using Apache telnet for connecting to a MUD game.

Here's my output:

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.

wheras here's the standard telnet output:

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):

This is, I think, because of how lines are handled in 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...
    }

}

I'm fairly sure it's while (line != null) { in readInputStream which is problematic. Not every line is getting passed, I think.

0

There are 0 answers