public void writeData(SpoutOutputStream output) throws IOException {
output.writeInt(widget.getType().getId());
output.writeUUID(screen);
output.writeUUID(widget.getId());
SpoutOutputStream data = new SpoutOutputStream();
widget.writeData(data);
ByteBuffer buffer = data.getRawBuffer();
byte[] widgetData = new byte[buffer.capacity() - buffer.remaining()];
System.arraycopy(buffer.array(), 0, widgetData, 0, widgetData.length);
output.writeInt(widgetData.length);
output.writeShort((short) widget.getVersion());