News:

Facebook killed the radio star. And by radio star, I mean the premise of distributed forums around the internet. And that got got by Instagram/SnapChat. And that got got by TikTok. Where the fuck is the internet we once knew?

Main Menu

[GENERAL/JAVA] Battle.net newline character

Started by dynobird, August 26, 2005, 10:29:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dynobird

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.

MyndFyre

Depends on the protocol.  Binary -- there is no newline.  Text -- CRLF.
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

Warrior

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

dynobird

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);
            }
        }
    }



Newby

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

Quote from: Rule on June 30, 2008, 01:13:20 PM
Quote from: CrAz3D on June 30, 2008, 10:38:22 AM
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. 

rabbit


Joe

Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


iago


rabbit

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.

Joe

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.
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.