Clan x86

Technical (Development, Security, etc.) => General Programming => Botdev => Topic started by: dynobird on August 26, 2005, 10:29:09 PM

Title: [GENERAL/JAVA] Battle.net newline character
Post by: dynobird on August 26, 2005, 10:29:09 PM
What char(s) does BNet send to signify a new line? I figure it must send something to signify it (and its gotta be something the computer recognizes...) because when I do this to receive


while(true) {
    updateWindow.setNewText((char)in.read());
}


It makes a new line for different messages, even if they don't fill up the horizontal width of the display area.

I tried \n but it didn't work... I need to know the newline character so I can parse individual messages (like the message sent after a user pressed "enter") into Strings and then recognize commands within these Strings with the StringTokenizer class. Right now I am just doing what I showed above, reading char by char.
Title: Re: [GENERAL/JAVA] Battle.net newline character
Post by: MyndFyre on August 26, 2005, 10:30:42 PM
Depends on the protocol.  Binary -- there is no newline.  Text -- CRLF.
Title: Re: [GENERAL/JAVA] Battle.net newline character
Post by: Warrior on August 26, 2005, 10:33:39 PM
Carraige Return Line Feed! :O (random guess)
Title: Re: [GENERAL/JAVA] Battle.net newline character
Post by: dynobird on August 26, 2005, 10:58:27 PM
Well, I made some progress in the parsing, I now only get semi-cryptic messages on my display area =P
What I get is a bunch of boxes and every once in a while I get the messages I'm supposed to get like: "TALK usernamehere: hi" "LEAVE usernamehere" but inbetween these messages i get about a 1000 boxes that go all the way horizontally and then down like 20 lines vertically.

Here's my code:

    /* run method in receive thread */
    public void run() {
        int i;
        char[] charsIn;
        while (true) {
            i = 0;
            charsIn = new char[10000];
            try {
                /*
                newWindow.setNewText((char)in.read());
                newWindow.setVisible(true);
                */
                do {
                    charsIn[i] = (char)in.read();
                    i++;
                }
                while (charsIn[i-1] != '\n');
                String message = String.copyValueOf(charsIn);
                newWindow.setNewText(message);
            }
            catch (IOException e) {
                System.out.println(e);
            }
        }
    }


Title: Re: [GENERAL/JAVA] Battle.net newline character
Post by: Newby on August 26, 2005, 11:02:20 PM
string[] IncomingData = IncomingInfo.Split("\r\n".ToCharArray());

That's what I did in C#. Not sure if that helps in Java.

Check out my C# .NET telnet connection. See if it helps you any.

On the note of the boxes, check what ASCII value they are and remove them!
Title: Re: [GENERAL/JAVA] Battle.net newline character
Post by: rabbit on August 27, 2005, 01:12:09 AM
10 and 13.
Title: Re: [GENERAL/JAVA] Battle.net newline character
Post by: Joe on August 27, 2005, 05:53:33 AM
13 and 10*

\n\t
Title: Re: [GENERAL/JAVA] Battle.net newline character
Post by: iago on August 27, 2005, 12:14:48 PM
Quote from: Dishfoot on August 27, 2005, 05:53:33 AM
13 and 10*

\n\t

\t is tab

It's \r\n, or 0d 0a, or 13 10
Title: Re: [GENERAL/JAVA] Battle.net newline character
Post by: rabbit on August 27, 2005, 04:05:58 PM
Quote from: Dishfoot on August 27, 2005, 05:53:33 AM
13 and 10*

\n\t
I never said "respectively", indicating which value was for which character; I merely gave the two values.
Title: Re: [GENERAL/JAVA] Battle.net newline character
Post by: Joe on August 30, 2005, 09:14:31 AM
Hehe, found that out for myself in writing some C++ code, where I tried to use a CRLF in a message box. Yeah, I meant \n.