RtdeTextMessage.java 1022 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package at.acdp.urweb.rtde.packets;
  2. import java.io.DataInputStream;
  3. import java.io.DataOutputStream;
  4. import java.io.IOException;
  5. import static at.acdp.urweb.rtde.CommandType.RTDE_TEXT_MESSAGE;
  6. public class RtdeTextMessage implements IRtdeData {
  7. private int replySize;
  8. public String text;
  9. public String source;
  10. public int warningLevel;
  11. @Override
  12. public int getType() {
  13. return RTDE_TEXT_MESSAGE;
  14. }
  15. @Override
  16. public RtdeTextMessage read(DataInputStream di, int length) throws IOException {
  17. int mLength=di.readByte();
  18. byte[] msgb=new byte[mLength];
  19. di.readFully(msgb);
  20. text=new String(msgb);
  21. int sLength=di.readByte();
  22. byte[] sourceb=new byte[sLength];
  23. di.readFully(sourceb);
  24. source=new String(sourceb);
  25. warningLevel=di.readByte();
  26. return this;
  27. }
  28. @Override
  29. public RtdeTextMessage send(DataOutputStream dos) throws IOException {
  30. sendHeader(dos,0);
  31. return this;
  32. }
  33. }