public void SendPacket(OutputStream out, boolean packetLog) throws IOException, SocketException {
byte data[] = ((ByteArrayOutputStream)this.out).toByteArray();
//BNCSOutputStream sckout = new BNCSOutputStream(out);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BNetOutputStream sckout = new BNetOutputStream(baos);
if(packetId == BNCSCommandIDs.SID_CHATCOMMAND) {
if(data.length > 0xFB) {
Out.error(this.getClass().getName(), "Chat command is too long; ignoring.");
return;
}
if(data[data.length-1] != 0x00) {
Out.error(this.getClass().getName(), "Chat command is not null terminated; ignoring.");
return;
}
}
try {
sckout.writeByte(0xFF);
sckout.writeByte(packetId);
sckout.writeWord(data.length + 4);
sckout.write(data);
} catch(IOException e) {
e.printStackTrace();
System.exit(1);
}