/********************************************************************** Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html Contributors: Vicente Fernando - www.alfersoft.com.ar - Initial implementation **********************************************************************/ package net.sourceforge.phpdt.internal.debug.core; import java.io.OutputStream; import java.util.Vector; import java.io.IOException; public class PHPDBGPacket { private static final int PACKET_HEADER_SIZE= 16; private char[] packetHeader= new char[PACKET_HEADER_SIZE]; private int packetSize; private Vector frames= new Vector(); public PHPDBGPacket(char[] packetType) { PHPDBGBase.copyChars(packetHeader, PHPDBGBase.DBGSYNC, 4); PHPDBGBase.copyCharsTo(packetHeader, packetType, 4, 4); } public void addFrame(PHPDBGFrame frame) { frames.add(frame); packetSize+= frame.getSize(); } public void sendPacket(OutputStream out) throws IOException { int i; PHPDBGFrame frame; PHPDBGBase.copyCharsTo(packetHeader, PHPDBGBase.IntToChar4(packetSize), 4, 12); // Send packet header out.write(PHPDBGBase.CharArrayToByteArray(packetHeader)); out.flush(); // Send Frames for(i=0; i < frames.size(); i++) { // Header of frame frame= (PHPDBGFrame)frames.get(i); out.write(PHPDBGBase.CharArrayToByteArray(frame.getHeader())); out.flush(); if (frame.getSizeOfData() > 0) { // Data of frame out.write(PHPDBGBase.CharArrayToByteArray(frame.getFrameData())); out.flush(); } } } }