Author Topic: [GENERAL/JAVA] Battle.net newline character  (Read 5867 times)

0 Members and 1 Guest are viewing this topic.

Offline dynobird

  • Newbie
  • *
  • Posts: 26
  • I'm new here!
    • View Profile
[GENERAL/JAVA] Battle.net newline character
« 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

Code: [Select]
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.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [GENERAL/JAVA] Battle.net newline character
« Reply #1 on: August 26, 2005, 10:30:42 pm »
Depends on the protocol.  Binary -- there is no newline.  Text -- CRLF.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Warrior

  • supreme mac daddy of trolls
  • Hero Member
  • *****
  • Posts: 7503
  • One for a Dime two for a Quarter!
    • View Profile
Re: [GENERAL/JAVA] Battle.net newline character
« Reply #2 on: August 26, 2005, 10:33:39 pm »
Carraige Return Line Feed! :O (random guess)
One must ask oneself: "do I will trolling to become a universal law?" And then when one realizes "yes, I do will it to be such," one feels completely justified.
-- from Groundwork for the Metaphysics of Trolling

Offline dynobird

  • Newbie
  • *
  • Posts: 26
  • I'm new here!
    • View Profile
Re: [GENERAL/JAVA] Battle.net newline character
« Reply #3 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:
Code: [Select]
    /* 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);
            }
        }
    }


Offline Newby

  • x86
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: [GENERAL/JAVA] Battle.net newline character
« Reply #4 on: August 26, 2005, 11:02:20 pm »
Code: [Select]
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!
- Newby
http://www.x86labs.org

Quote
[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: [GENERAL/JAVA] Battle.net newline character
« Reply #5 on: August 27, 2005, 01:12:09 am »
10 and 13.

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: [GENERAL/JAVA] Battle.net newline character
« Reply #6 on: August 27, 2005, 05:53:33 am »
13 and 10*

\n\t
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: [GENERAL/JAVA] Battle.net newline character
« Reply #7 on: August 27, 2005, 12:14:48 pm »
13 and 10*

\n\t

\t is tab

It's \r\n, or 0d 0a, or 13 10

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: [GENERAL/JAVA] Battle.net newline character
« Reply #8 on: August 27, 2005, 04:05:58 pm »
13 and 10*

\n\t
I never said "respectively", indicating which value was for which character; I merely gave the two values.

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
Re: [GENERAL/JAVA] Battle.net newline character
« Reply #9 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.
I'd personally do as Joe suggests

You might be right about that, Joe.