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.
Depends on the protocol. Binary -- there is no newline. Text -- CRLF.
Carraige Return Line Feed! :O (random guess)
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);
}
}
}
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!
10 and 13.
13 and 10*
\n\t
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
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.
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.