Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. package server.net;
  2.  
  3. import io.netty.buffer.ByteBuf;
  4.  
  5. /**
  6. * Represents a payload of bytes that can be transmitting through streams.
  7. *
  8. * @author Ryley Kimmel <ryley.kimmel@live.com>
  9. */
  10. public final class NettyPacket {
  11.  
  12. private final int opcode;
  13. private final int length;
  14. private final ByteBuf payload;
  15.  
  16. public NettyPacket(ByteBuf payload) {
  17. this(-1, payload);
  18. }
  19.  
  20. public NettyPacket(int opcode, ByteBuf payload) {
  21. this.opcode = opcode;
  22. length = payload.writableBytes();
  23. this.payload = payload;
  24. }
  25.  
  26. public NettyPacket(int opcode, int length, ByteBuf payload) {
  27. this.opcode = opcode;
  28. this.length = length;
  29. this.payload = payload;
  30. }
  31.  
  32. public int getOpcode() {
  33. return opcode;
  34. }
  35.  
  36. public int getLength() {
  37. return length;
  38. }
  39.  
  40. public ByteBuf getPayload() {
  41. return payload;
  42. }
  43.  
  44. public byte[] array() {
  45. return payload.array();
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement