• Welcome to Valhalla Legends Archive.
 

Java debuffer

Started by OldMcDonald, April 23, 2010, 04:58 PM

Previous topic - Next topic

OldMcDonald

I got the response from bnet as an inputstream. I wanna debuff the input stream which means I would have to break it down, assign it to a byte array and send it to iagos buffer class.

I know there is an easier way to do it so I'm looking for other ways. If anyone has sample source codes I can look or suggest something other than input please do so.

Hdx

There is no real wrapper for a Stream class to 'debuff' data.
use .Read() in the Stream class to manually read a process the header. Then read the actual data in a big chunk. And pass it off to iago's Buffer class for processing.

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

OldMcDonald

so the read() takes out header info huh... which header we talking about? the ff 50 and length? Does it read it only or does it remove as well?

Also what wud be best to do with the info...
Should i place everything into an byte array and pass it on to buffer?


Hdx

Why don't you teach yourself how to read the JavaDocs
Its easy to figure out what to do.

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

OldMcDonald

yea i know that but im saying does the input stream grab the whole entire packet? Or just the data + the bnet header?

Hdx

Think of the input stream as a byte stream of the tcp data without the tcp header.
.Read() reads 1 byte and removes it from the stream.

So, in theory for the following packet:
FF 00 04 00
The first time you call .Read() it should return 0xFF, 2nd time returns 0x00, 3rd - 0x04, etc....

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

OldMcDonald

mmk thanks for explaining that lol. I'll see how it goes and ill ask more questions here.