Examples of BNetOutputStream


Examples of net.bnubot.core.BNetOutputStream

  }
 
  public void SendPacket(OutputStream out, boolean packetLog) {
    byte data[] = ((ByteArrayOutputStream)this.out).toByteArray();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    BNetOutputStream sckout = new BNetOutputStream(baos);
   
    try {
      sckout.writeWord(data.length + 3);
      sckout.writeByte(packetId);
      sckout.write(data);
    } catch(IOException e) {
      e.printStackTrace();
      System.exit(1);
    }
   
View Full Code Here

Examples of net.bnubot.core.BNetOutputStream

    for(int i = 0; i < packetLength-3; i++) {
      data[i] = is.readByte();
    }
   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    BNetOutputStream os = new BNetOutputStream(baos);
    os.writeByte(packetId);
    os.writeWord(packetLength);
    os.write(data);
   
    if(packetLog)
      Out.info("MCPPacketReader", "RECV MCP\n" + HexDump.hexDump(baos.toByteArray()));
  }
View Full Code Here

Examples of net.bnubot.core.BNetOutputStream

    for(int i = 0; i < packetLength-4; i++) {
      data[i] = is.readByte();
    }
   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    BNetOutputStream os = new BNetOutputStream(baos);
    os.writeByte(0xFF);
    os.writeByte(packetId);
    os.writeWord(packetLength);
    os.write(data);
   
    if(packetLog)
      Out.info(this.getClass().getName(), "RECV\n" + HexDump.hexDump(baos.toByteArray()));
  }
View Full Code Here

Examples of net.bnubot.core.BNetOutputStream

 
  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);
    }
   
View Full Code Here

Examples of net.bnubot.util.BNetOutputStream

  @Override
  protected void initializeConnection(Task connect) throws Exception {
    s = new Socket(getServer(), getPort());
    is = new BNetInputStream(s.getInputStream());
    os = new BNetOutputStream(s.getOutputStream());
    //Chat
    //os.writeByte(0x03);
    //os.writeByte(0x04);
  }
View Full Code Here

Examples of net.bnubot.util.BNetOutputStream

    Out.info(BNFTPConnection.class, "Downloading " + fileName + "...");
    try (
      Socket s = new Socket(cs.server, cs.port);
      BNetInputStream is = new BNetInputStream(s.getInputStream());
      BNetOutputStream os = new BNetOutputStream(s.getOutputStream());
    ) {
      //FTP
      os.writeByte(0x02);

      //File request
      os.writeWord(32 + fileName.length() + 1);
      os.writeWord(0x100);    // Protocol version
      os.writeDWord(PlatformIDs.PLATFORM_IX86)// Platform ID
      os.writeDWord(cs.product.getDword())// Product ID
      os.writeDWord(0);    // Banners ID
      os.writeDWord(0);    // Banners File Extension
      os.writeDWord(0);    // File position
      os.writeQWord(0);    // Filetime
      os.writeNTString(fileName);

      long startTime = System.currentTimeMillis();
      while(is.available() == 0) {
        if(s.isClosed() || (System.currentTimeMillis() - startTime) > 500)
          throw new Exception("BNFTP download failed");
View Full Code Here

Examples of net.bnubot.util.BNetOutputStream

              byte[] data = new byte[33];
              is.read(data);
              if(is.readByte() != 0)
                throw new Exception("invalid statstr format\n" + HexDump.hexDump(baos.toByteArray()));

              try (BNetOutputStream bos = new BNetOutputStream(baos)) {
                bos.write(("PX2D[Realm]," + name + ",").getBytes());
                bos.write(data);
                bos.writeByte(0);
              }
              final StatString statstr = new StatString(new BNetInputStream(new ByteArrayInputStream(baos.toByteArray())));

              MCPCharacter c = new MCPCharacter(time, name, statstr);
View Full Code Here

Examples of net.bnubot.util.BNetOutputStream

    if(GlobalSettings.packetLog) {
      String msg = "RECV " + packetId.name();
      if(Out.isDebug()) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try (BNetOutputStream os = new BNetOutputStream(baos)) {
          os.writeByte(packetId.ordinal());
          os.writeWord(packetLength);
          os.write(data);
        }
        msg += "\n" + HexDump.hexDump(baos.toByteArray());
      }
      Out.debugAlways(getClass(), msg);
    }
View Full Code Here

Examples of net.bnubot.util.BNetOutputStream

      icon.xSize = icon.getIcon().getIconWidth();
      icon.ySize = icon.getIcon().getIconHeight();
    }

    try (
      BNetOutputStream os = new BNetOutputStream(new FileOutputStream(f));
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      BNetOutputStream headerStream = new BNetOutputStream(baos);
    ) {
      Out.debug(IconsDotBniReader.class, "Writing " + f.getName());

      headerStream.writeWord(1); // BNI version
      headerStream.writeWord(0); // Alignment Padding (unused)
      headerStream.writeDWord(icons.length); // numIcons
      headerStream.writeDWord(-1); // dataOffset

      for(BNetIcon icon : icons) {
        headerStream.writeDWord(icon.flags);
        headerStream.writeDWord(icon.xSize);
        headerStream.writeDWord(icon.ySize);

        //Write up to 32 products; stop if we see a null
        for(int product : icon.products) {
          if(product == 0)
            break;
          headerStream.writeDWord(product);
        }
        headerStream.writeDWord(0);
      }


      byte[] header = baos.toByteArray();
      os.writeDWord(header.length);
View Full Code Here

Examples of net.bnubot.util.BNetOutputStream

  public void sendPacket(OutputStream out) {
    byte data[] = ((ByteArrayOutputStream)this.out).toByteArray();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    try (BNetOutputStream sckout = new BNetOutputStream(baos)) {
      sckout.writeWord(data.length + 3);
      sckout.writeByte(packetId.ordinal());
      sckout.write(data);
    } catch(IOException e) {
      Out.fatalException(e);
    }

    data = baos.toByteArray();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.